‎2009 Aug 31 7:55 PM
the result is 98,067 and I want to show 98,07 but if the result 98,064 I want to show 98,06 simple rules of rounding !!, but How can I do that within the program? . Is there a easy way to do that?.
I have fixed point arithmetic uncheked for this code:
DATA: lv_kwert2 TYPE p DECIMALS 3,
gv_kwert2 LIKE konv-kwert,
tvbdpr-fkimg LIKE VBDPR-fkimg.
lv_kwert2 = ( gv_kwert2 * 10000 ) / tvbdpr-fkimg.
Debugging the program you get the following values:
lv_kwert2 = 0.000
gv_kwert2 = 294.20
tvbdpr-fkimg = 3.000
After executing the calculation value for lv_kwert2 is 98.067. I need to round this value.
any idea would be very much appreciated.
thanks all in advance
‎2009 Aug 31 11:20 PM
when "fixed point arithmetic" flag is unchecked, operations on packed numbers are done as if they had no decimals at all. In your case, to round, you just have to divide by 10 (the least significant digit is cut with a commercial rounding on the previous digit), and multiply by 10.
lv_kwert2 = ( gv_kwert2 * 10000 ) / tvbdpr-fkimg / 10 * 10.(yes I know, it's very difficult to understand, but logic with my initial explanation)
But using ROUND FM which works with "fixed point arithmetic", it's much more easier (though slower). Note that this FM has documentation. Use parameter SIGN='X' to get a commercial rounding.
‎2009 Aug 31 8:07 PM
just use keywords like CEIL,FLOOR,TRUNC,with the variable.
like
n = func( m ).
check out this link
[Mathematical functions|http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3316358411d1829f0000e829fbfe/content.htm]
and with write statement you can use ROUND<n>
check this
[Formatting Options|http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9e3d35c111d1829f0000e829fbfe/content.htm]
‎2009 Aug 31 8:33 PM
Hi,
Use the FM ROUND...and choose to have 1 decimal points.
Regards,
Himanshu
‎2009 Aug 31 11:20 PM
when "fixed point arithmetic" flag is unchecked, operations on packed numbers are done as if they had no decimals at all. In your case, to round, you just have to divide by 10 (the least significant digit is cut with a commercial rounding on the previous digit), and multiply by 10.
lv_kwert2 = ( gv_kwert2 * 10000 ) / tvbdpr-fkimg / 10 * 10.(yes I know, it's very difficult to understand, but logic with my initial explanation)
But using ROUND FM which works with "fixed point arithmetic", it's much more easier (though slower). Note that this FM has documentation. Use parameter SIGN='X' to get a commercial rounding.