Skip to Content

Inconsistent Number Formats in ABSL-functions

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Jul 11, 2016 at 12:51 PM

    Hello Pablo,

    I will try to make the ParseFromString more "intelligent". 😎

    Earliest in the next release.

    Stay tuned,

    Horst

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.