Forums
I’m trying to retrieve a decimal number into a decimal field with the "NUM(Xml_GetValue" command.
Example-1:
<ns5:LineExtensionAmount>163.25</ns5:LineExtensionAmount>
Example-2:
<ns5:LineExtensionAmount>244.5</ns5:LineExtensionAmount>
In example-1 I get the value 16325 and I example-2 the value: 2445
How can I retrieve a decimal value into a decimal field?
Decimal point
Hi Jens Erik.
By default the decimal point is selected by the IBMI job so it will adapt the locale decimal point. However what you are doing is more like extracting data from an XML file or JSON where the decimal point always are "."
In that case you can call the SetDecimalPoint('.') once in you code initialization- this will override the decimal point from the IBMi job.
If you need to do it in a mixed environment - then the Num function actually takes an extra parameter - the decimal point.
so in the mixed environment - in the same code you can do some ting similar to:
n1 = num(fromBrowserString);
n2 = num(fromXmlString : '.');
So the first n1 takes the decimal point by locale - i.e. the IBMi job description or current value. The second n2 has the decimal point explicitly set to '.'
Not only Num() works that way - this behavior also apply to:
n = qryStrNum('QueryStringField' : defaultValue : ',');
n = formNum('formField' : defaultValue: ',');
n = reqNum('formOrQryStrFiled' : defaultValue : ',');
Hopes this helps
Regards
Niels
Hi Niels Thanks for you
Hi Niels
Thanks for you answer. It works now
Regards, Jens Erik