2005 Nov 25 1:55 AM
I'm doing something like
DATA var1 TYPE p DECIMALS 2.
.
.
.
var1 = 364 / 365.
I expect to receive "0.99" but instead of I receive "1.00".
Can someone explain me a little, of how to work with decimals in ABAP?
Thanx in advance.
2005 Nov 25 2:08 AM
I'm doing something like
DATA var1 TYPE p DECIMALS 2.
.
.
.
var1 = 364 / 365.
I expect to receive "0.99" but instead of I receive "1.00".
Can someone explain me a little, of how to work with decimals in ABAP?
Thanx in advance.
2005 Nov 25 2:08 AM
2005 Nov 25 2:24 AM
If you need it to be 2 decimals places, then you can do something like this. There must be a better way, I can't seem to give you one at the moment.
report zrich_0001.
DATA var1 TYPE p DECIMALS 3.
data: xvar1(10) type c.
data: xvar2 type p decimals 2.
var1 = 364 / 365.
write var1 to xvar1.
shift xvar1 right deleting trailing space.
shift xvar1 right by 1 places.
xvar2 = xvar1.
write:/ xvar2.
REgards,
Rich Heilman
2005 Nov 25 2:26 AM
The system will always want to round up. If you values where just a little different, of course it would show the decimal.
report zrich_0001.
DATA var1 TYPE p DECIMALS 2.
var1 = <b>360</b> / 365.
write:/ var1. " VALUE is .99
If you find these answers a little helpful, please award points accordingly, Thanks.
Regards,
Rich Heilman
2005 Nov 25 2:46 AM
If you always want to round down the divsion, here is a better way. Not sure what I was thinking, maybe too much Thanksgiving Turkey.
report zrich_0001.
DATA var1 TYPE p DECIMALS 2.
var1 = ( floor( ( 364 / 365 ) * 100 ) ) / 100.
WRITE:/ var1.
Here we are doing the division, multpling by 100 for the decimal places(value now is 99.7) then round down using FLOOR(value now is 99.0, then dividing by 100 for the 2 decimals places(value now is .99
Regards,
Rich Heilman
2005 Nov 25 2:58 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |