2007 Jun 04 6:22 AM
i have an amt field of currency type.
i want to round off the value like if the value is 2019.50 then it shud be
2020.00 . how can i do it..
Thanks
2007 Jun 04 6:27 AM
try this
DATA: I TYPE I,
P TYPE P DECIMALS 2,
M TYPE F VALUE '-3.5',
D TYPE P DECIMALS 1.
I = CEIL( P ). " 4 - next largest whole number
I = CEIL( M ). " -3
I = FLOOR( P ). " 3 - next smallest whole number
I = FLOOR( M ). " -4
I = TRUNC( P ). " 3 - integer part
I = TRUNC( M ). " -3
D = FRAC( P ). " 0.5 - decimal part
D = FRAC( M ). " -0.5
regards
shiba dutta
try this
DATA: I TYPE I,
P TYPE P DECIMALS 2,
M TYPE F VALUE '-3.5',
D TYPE P DECIMALS 1.
I = CEIL( P ). " 4 - next largest whole number
I = CEIL( M ). " -3
I = FLOOR( P ). " 3 - next smallest whole number
I = FLOOR( M ). " -4
I = TRUNC( P ). " 3 - integer part
I = TRUNC( M ). " -3
D = FRAC( P ). " 0.5 - decimal part
D = FRAC( M ). " -0.5
regards
shiba dutta
2007 Jun 04 6:24 AM
2007 Jun 04 6:27 AM
try this
DATA: I TYPE I,
P TYPE P DECIMALS 2,
M TYPE F VALUE '-3.5',
D TYPE P DECIMALS 1.
I = CEIL( P ). " 4 - next largest whole number
I = CEIL( M ). " -3
I = FLOOR( P ). " 3 - next smallest whole number
I = FLOOR( M ). " -4
I = TRUNC( P ). " 3 - integer part
I = TRUNC( M ). " -3
D = FRAC( P ). " 0.5 - decimal part
D = FRAC( M ). " -0.5
regards
shiba dutta
2007 Jun 21 4:43 PM
2007 Jun 04 6:27 AM
Hi
check the following Functions
following maths functionas are there in SAP:
<b>abs</b> -Absolute value of the argument arg
<b>sign-</b> Plus/minus sign of the argument arg: -1, if the value of arg is negative; 0 if the value of arg is 0; 1 if the value of arg is positive.
<b>ceil</b> -Smallest integer number that is not smaller than the value of the argument arg.
<b>floor-</b> Largest integer number that is not larger than the value of the argument arg.
<b>trunc-</b> Value of the integer part of the argument arg
<b>frac-</b> Value of the decimal places of the argument arg
Reward points if useful
Regards
Anji
2007 Jun 04 6:30 AM
Hi,
hope u can use the function module ROUND.
Reward points if it is helpful.
Regards,
Sangeetha.
2007 Jun 04 3:23 PM
Hi,
Use ROUND aggregate function.
Ex.
DATA pack TYPE p VALUE '123.456'
DECIMALS 3.
WRITE pack DECIMALS 2.
WRITE: / pack ROUND -2,
/ pack ROUND -1,
/ pack ROUND 1,
/ pack ROUND 2.
Output:
123,46
12.345,600
1.234,560
12,346
1,235
Regards,
Bhaskar
2007 Jun 04 3:55 PM
1.
check the Fm Round_amount.
or ..
2.
logic has to be build this way
parameters : price like vbap-netwr .
data : val type i .
data : rem type p decimals 2.
rem = frac( price ).
rem = rem * 100.
if rem ge 50.
val = abs( price ).
move val to price.
write price.
else.
write:/ price.
endif.
like if the input is 2019.20 o/p will be 2019.20 only
if the input is 2019.51 o/p will be 2020.00.
check this .
3.
try the variation
write value curreny 'X' round 'Y' DECIMALS 'Z'.
CHECK this option as well.
Vijay
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |