Skip to Content
0
Jun 22, 2016 at 01:21 PM

Inconsistent Number Formats in ABSL-functions

1047 Views

Hey Guys,

just had an issue with displaying / rounding of numbers and wanted to share the solution with you.

Problem statement

The ABSL-functions Numeric.ParseFromString(s) and Numeric.RoundToString(n) expect/provide different number formats.


> Numeric.ParseFromString(s) expects the decimal separator to be a "." (anglican style)


> Numeric.RoundToString(n) might return a string with a "," as decimal separator (if the user's locale has assigned the continental style).


That may lead to problems when e.g. doing stuff like: Numeric.ParseFromString(someNumber.RoundToString(2));

> You will get an "Invalid importing parameter STRING"-Error.

Solution

> To avoid this, you can set a flag in the RoundToString-function to force always returning a dot as separator:


Numeric.ParseFromString(someNumber.RoundToString(2, true));


Implications for SAP

1) If Numeric.RoundToString(n) changes based on the user's locale, Numeric.ParseFromString(s) should also behave the same way.


2) Even better would be if the Numeric.ParseFromString(s)-function supported both kinds of decimal-separators.


3) Finally, there should also be a function that rounds a Numeric without conversion to string, for convenience and performance reasons.

Cheers

Pablo