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

rounding of decimals

HI Experts,

I have issue in roundign of decimals. I need to round the values to 3 decimal places. But the sum of the values shud be 1.

Ex - 0.434456184, 0.483094697,0.082449119 are the three values. Their sum is 1. But if i reduce them to 3 decimal places i get only total as 0.999. If i use ROUND Funciton module i get the total as 1.001.

These values i am updating in Kp26 transaction which will allow me only 3 decimal places. Can you please help me reduce them to 3 decimal places and also not affecting the sum?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 11:33 AM

    Hi,

    >

    TRY LIKE THIS.

    Data: a type p length 16 decimals 0.

    a = '.999'.

    a = ceil( a ).

    write:/ 'ceil', a.

    a = floor( a ).

    write:/ 'floor', a.

    hope the above snippet makes things cleareer for u,

    Regards,

    Chaitanya.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 28, 2008 at 03:40 AM

    Hi,

    You can do something like this :

    data : a type p decimals 4,

    b type p decimals 4,

    c type p decimals 4,

    final type p decimals 3.

    a = '0.434456184'.

    b = '0.483094697'.

    c = '0.082449119'.

    final = a + b + c.

    write final. => the value is 1.

    this will ensure that you get the exact value and also the output is 1.

    Otherwise if you want all the values should be only 3 decimals you can check if the value is .999 then out as 1.

    Regards,

    Narayani

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 04:32 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 05:05 AM

    Hi Haresha,

    Go to OY04 and maintain decimals as 3 there.

    pls reward if helps.

    cheers,

    Hema.

    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.