01-27-2008 6:37 PM
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?
01-28-2008 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.
01-28-2008 3: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
01-28-2008 4:32 AM
Hai.
Check this.
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9e3d35c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_40b/helpdata/es/34/8e732f6df74873e10000009b38f9b8/content.htm
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/write_op.htm
http://abapprogramming.blogspot.com/2007/06/lesson-21-statements.html
Regards.
Sowjanya.B.
01-28-2008 5:05 AM
Hi Haresha,
Go to OY04 and maintain decimals as 3 there.
pls reward if helps.
cheers,
Hema.
01-28-2008 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.