04-21-2008 8:22 AM
Hi ,
I have a requirement to round of the value 600.00, to 600.But if the variable contains 600.50, then the value should not change ,it should remain as it is.Only if the value after the decimal point is initial , then it should round off.
Is there any function module or command to do this?? I dont want to use split statement.Please guide.
Thanks,
Ruby.
04-21-2008 10:03 AM
Hi
Try with these commands for rounding a value
ceil :Smallest integer number that is not smaller than the value of the argument arg.
floor :Largest integer number that is not larger than the value of the argument arg.
Thnx
Sravani
Plz rewrd points......
04-21-2008 10:06 AM
hi check this..
data: nu(10) type p decimals 4.
data: nu1(5) type p decimals 2.
nu = '4.017'.
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = 2
INPUT = nu
SIGN = ' '
IMPORTING
OUTPUT = nu1
EXCEPTIONS
NPUT_INVALID = 1
OVERFLOW = 2
*TYPE_INVALID = 3
OTHERS = 4
regards,
venkat
04-21-2008 10:11 AM
04-21-2008 10:28 AM
Chacko,
You need to change the datatype to get it printed as 600,as long as the datatype is curr it will print as 600.00.
600.00 itself means rounded off,so the problem is not to round off but only to print without decimals when it is 600.00 and with decimals when it is 600.50
use offset and move 600 to a different variable when 600.00,when 600.50 print it as it is.
data: temp1 like bseg-wrbtr value '600',
temp2 like bseg-wrbtr value '600.00',
temp3 like bseg-wrbtr value '600.50',
temp4(15) type c,
temp5(13) type c,
temp6(2) type c.
move temp3 to temp4.
split temp4 at '.' into temp5 temp6.
if temp6 = '00'.
write:/ 'without decimals-', temp5.
else.
write:/ 'with decimals-',temp3.
endif.
K.Kiran.
04-21-2008 10:18 AM
try to split the value into two variables ...
data : v_data(20).
v_data = '600.00'.
split v_data at '.' into v_data1 v_data2.
if v_data2 is initial.
*use v_data1.
else.
*use v_data.
endif.
04-21-2008 10:37 AM
Hi,
So is there no other options, other than using split statement?
04-21-2008 10:57 AM
Chacko,
With type P we can't use offset,so I guess split is the way to achieve this.
K.Kiran.
04-21-2008 10:52 AM
Hi,
USE THE BELOW MENTIONED FM
J_1I6_ROUND_TO_NEAREST_AMT
Note; Please reward points, if found suitable.
Regards,
IFF