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?
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
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.
Add a comment