XML import with XMLDOM, decimal format

Dennis_Decoene
Member Posts: 123
Hi,
We have a working xml import with the xml DOM objects. Originally the codeunit was written in a Belgian NAV. Number where read correctly. Now the same codeunit is in a UK Nav DB, running on a pc with locale UK. Numbers are wrong.
This is the XML:
In the BE DB this imports as 3.173,25 => Correct
In the UK it imports as 317,325.00 => Wrong
Why?
We have a working xml import with the xml DOM objects. Originally the codeunit was written in a Belgian NAV. Number where read correctly. Now the same codeunit is in a UK Nav DB, running on a pc with locale UK. Numbers are wrong.
This is the XML:
<PROPERTY PROP_NAME="NETAMOUNT1">3173.25</PROPERTY>
In the BE DB this imports as 3.173,25 => Correct
In the UK it imports as 317,325.00 => Wrong
Why?
0
Comments
-
the local setting for the computer that identifies 1000 separator is comma and decimal separator is period in one computer and it's different in the other computer.
check the code how they are assigning the amount. If they are using format, you can write your own code.0 -
If you write the value through format, you need to use standard format number 9 to have the output XML compatible (it means use something like this: FORMAT(MyValue,0,9))0
-
I looked further into the code that is converting the string to decimal.
IF NOT EVALUATE(TotalAmount,CONVERTSTR(Value,'.',',')) THEN TotalAmount := 0;
Since in BE the decimal sign is "," this works. but for UK, a "," represents the thousand separator, hence wrong...
So, this would work in UK:IF NOT EVALUATE(TotalAmount,Value) THEN TotalAmount := 0;
But how to get it right under all circumstances?0 -
If the XML is valid XML, the decimal separator is dot in all cases. Now you can convert the string in this way:
EVALUATE(MyDecimal,CONVERTSTR(MyDecimalText,'.',DELCHR(FORMAT(0.1),'=','01')))
DELCHR(FORMAT(0.1),'=','01') - result is '.' or ',' depending on local settings
CONVERTSTR(MyDecimalText,'.',DELCHR(FORMAT(0.1),'=','01')) - replacing '.' (decimal separator in XML) by '.' or ',' depending on local settings
EVALUATE(..) - you know what it does... ;-)0 -
damn your smart...0
-
... I have only catched some things during last 25 years I am working with computers... ;-)0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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