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?

10|10000 characters needed characters exceeded

### Related questions

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.

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

10|10000 characters needed characters exceeded
• Former Member
Posted on Jan 28, 2008 at 04:32 AM
10|10000 characters needed characters exceeded
• 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.