Format Text
ReSpongebob
Member Posts: 17
Hi,
I'm rather new to Navision.
I'm asked to import data with a Dataport. The data imported does not always have the same format, as different users enter their data (everyone on his/her own way).
For example:
<= 50000
<= 50.000
<=50000
<=50.000
I need all this input in the same format:
* A space between the <, >, = and the actual number
* thousand-seperator
* decimal seperator
Both the input and the result are of type: Text
Is there a way to automate this with a pre-defined function or do I need to write a routine that checks the input-string character by character and adjust it as specified?
Please give me some information so I know how to solve this problem.
Thanks in advance!
I'm rather new to Navision.
I'm asked to import data with a Dataport. The data imported does not always have the same format, as different users enter their data (everyone on his/her own way).
For example:
<= 50000
<= 50.000
<=50000
<=50.000
I need all this input in the same format:
* A space between the <, >, = and the actual number
* thousand-seperator
* decimal seperator
Both the input and the result are of type: Text
Is there a way to automate this with a pre-defined function or do I need to write a routine that checks the input-string character by character and adjust it as specified?
Please give me some information so I know how to solve this problem.
Thanks in advance!
0
Comments
-
You can create function that returns separators for current user:
GetSeparator(VAR "Thousands Separator" : Text[1];VAR "Decimal Separator" : Text[1];VAR "Date Separator" : Text[1];VAR "Time Separator" //GetSeparator tx1 := FORMAT(010203D); p1 := STRPOS(tx1,'01'); p2 := STRPOS(tx1,'02'); p3 := STRPOS(tx1,'03'); "Date Separator" := ''; IF (p1<p2) AND (p2<p3) THEN "Date Separator" := COPYSTR(tx1,p1+2,1) ELSE IF (p2<p1) AND (p1<p3) THEN "Date Separator" := COPYSTR(tx1,p2+2,1) ELSE "Date Separator" := COPYSTR(tx1,p3+2,1); tx1 := FORMAT(151617T); p1 := STRPOS(tx1,'15'); // returns 0 at US 3:xx PM! p2 := STRPOS(tx1,'16'); p3 := STRPOS(tx1,'17'); "Time Separator" := ''; "Time Separator" := COPYSTR(tx1,p2-1,1); tx1 := FORMAT(123456/100); p1 := STRPOS(tx1,'1'); p2 := STRPOS(tx1,'2'); p3 := STRPOS(tx1,'4'); p4 := STRPOS(tx1,'5'); "Thousands Separator" := ''; "Decimal Separator" := ''; IF p2-p1 > 1 THEN "Thousands Separator" := COPYSTR(tx1,p1+1,1); IF p4-p3 > 1 THEN "Decimal Separator" := COPYSTR(tx1,p3+1,1);
In the beginning of the Dataport call this function:IUtils.GetSeparator(ThousSep,DecimSep,DateSep,TimeSep);
For Import, you must import all Decimals in Text variables and after that you must evaluate original fields:EVALUATE("Unit Price",CONVERTSTR(UnitPrice,'.',DecimSep));Stamen Delikostov
Navision Solution Developer
Intelligent Systems Bulgaria0 -
Thank you for your very quick reply

I think it's a usefull function that I am defenitly gonna use.
However, I don't know in advance what the user is going to enter.
For instance, the user needs to enter a value Less than 45000
It's possible the user enters:
<45000
But it's also possible that he will enter
< 45000 (or some other variant).
In order to get it into our database correctly, I need to format it to the same result, no matter what variant the user chooses.
The end-result I need to achieve must be:
< 45.000
My question now is:
How can I check wheter the space is present or not, and how to I insert one if the user omited it.
Same goes for the thousand-seperator. If the user didn't enter a thousand-seperator, I need to insert it myself.
Is this possible?0 -
For spaces, first you can delete all spaces, and after the symbols '<>=' insert one "space".
for the number you can evaluate it into a decimal variable and use FORMAT function to put thousand and descimal separator that you want.
For example:FORMAT(Number,0,'<Sign><Integer><Decimals,3><1000Character,.><Comma,.><Precision,2:2>')
Stamen Delikostov
Navision Solution Developer
Intelligent Systems Bulgaria0 -
Thank you so much, Stamen!
With your advice I managed to write the function I need.
=D>
Kind regards,0 -
I really don't understand how format function parameters work.
I have, in a text file a decimal field with this format:
127.53
where 127 is integer part
and
53 is decimal part
I want to insert it in a decimal variable and table field of Navision but it depends of regional settings.
I don't want it depends by Regional Setting. How is it possible?
I want alway 127.53 and not for example 127530.
Thank you very much0 -
You have to use FORMAT function only when you want to convert non-text variable to text variable.
When importing a text file, you must use EVALUATE instead of FORMAT. But first of all, you must convert decimal separator from "." to your separator, depending Regional Settings. It's simple:
//Find you decimal separator:
Str := FORMAT(123/2);
DecSep := COPYSTR(str,2,1);
//Read column form the text file in a text variable (for example ValueText), and convert '.' with your decimal separator:
IF decsep <> '.' THEN
ValueText := CONVERTSTR(ValueText,'.',DecSep);
//Convert the text variable to your decimal field:
EVALUATE("Decimal Field",ValueText);Stamen Delikostov
Navision Solution Developer
Intelligent Systems Bulgaria0 -
Thank you very much.
It seems correct but for having the decimal separator in the example the right code is:
DecSep := COPYSTR(str,3,1);
Have a nice day.0 -
Hi Everyone.
Anyone is meet with this error message?
FORMAT is not a function??? ](*,)
I do not know where shoud be the problem.
I have tried in an individually codeunit Format and there is working... could I mistake something??
This source is standard code of Item table, Costing Method OnValidate trigger.
Anyone have an idea what is this?
Thank you!
A
Okay, sorry, it was solved. recompile all objects! there was a new variable in a local function with the same name. Im .... :oops:0 -
Probably you have a field with name Format.
Is not good idea to use system words for naming fields, functions,...Stamen Delikostov
Navision Solution Developer
Intelligent Systems Bulgaria0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 330 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions