2006 Sep 06 8:20 AM
Hi!
I have a requirement in which I need to change the decimal place of a packed number. The value should not be rounded off. The decimal should be placed after the 10 thousandth place.
For eg. 3349544.88 should be displayed as 33.49.
Please help! Thanks in advance!
2006 Sep 06 8:47 AM
Hi,
data z type i value 10000.
data x type p decimals 2.
x = itab-val / i.
Message was edited by: Andreas Mann
Hi!
I have a requirement in which I need to change the decimal place of a packed number. The value should not be rounded off. The decimal should be placed after the 10 thousandth place.
For eg. 3349544.88 should be displayed as 33.49.
Please help! Thanks in advance!
2006 Sep 06 8:23 AM
Hai Jonathan,
If you are fixed with the number of digits, you can divide the result by a constant to get your answer.
2006 Sep 06 8:47 AM
Hi,
data z type i value 10000.
data x type p decimals 2.
x = itab-val / i.
Message was edited by: Andreas Mann
2006 Sep 06 8:52 AM
hi,
Use can try with this piece of code.
data: v_pack(10) type p decimals 2 value '3349544.8',
v_str(10) type c.
unpack v_pack to v_str.
shift v_str right by 5 places.
pack v_str to v_pack.
set country 'US'.
write :/ v_pack. "33.49
Regards,
Sailaja.
2006 Sep 06 9:07 AM
The below logic would work...if you always have 2 decimals.
unpack lval to lchr.
shift lchr right by 5 places.
write : / lchr using edit mask 'RR_____.__'.
*Use can use the format depending on the length of your *pack field
In case you have more variable decimal length.
lint = lp2.
unpack lint to lchr.
shift lchr right by 3 places.
write : / lchr no-zero using edit mask 'RR____.__'.
Regards
Anurag
-Just wanted you to check that if you use the divide by 100000 you can get rounding issues
Message was edited by: Anurag Bankley
Message was edited by: Anurag Bankley
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |