Skip to Content
author's profile photo Former Member
Former Member

Rouding off ...?

Hi ,

Can anybody help me with this requirement.

- if the number to print is integer, do not print comma.

- if the number to print is not integer, print 3 digit after comma.

Examples:

"128.32": NOT ALLOWED

"128.320": ALLOWED

"128.000": NOT ALLOWED

"128": ALLOWED.

Please let me know what is the procedure i need to follow to accomplish the task .

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Mar 26, 2009 at 05:46 PM

    Hi ,

    try this code...

    l_before " your value 128.32
    
    data : l_after  type p dec 3.
    
       l_after = FRAC( l_before ).
    
    if l_after > 0.
    l_after  = floor( l_before  ).
    else.
    l_after  = l_before.
    endif.
    
    

    if input is 124.23 output 124.230

    if input is 124.00 output 124.

    regards,

    Prabhudas

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Prabhu,

      I had tried your sample code i have not got the expected output.

      Here is the code that i have used.

      data : i_before1 type p DECIMALS 2 ,

      i_after type p DECIMALS 3.

      i_after = FRAC( i_before ).

      if i_after > 0.

      i_after = floor( i_before ).

      else.

      i_after = i_before.

      input given is : 125.45

      the output got is : 125.000

      But the expected output is 125.450

      if input given is : 125

      the output got is : 125.000

      but the expected ouput is : 125

      Can you please check

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.