‎2007 Oct 04 1:33 PM
hi experts,
How to get decimla values .
i have used field type p decimals 2.
if 2345.5 then it is coming 2345.5
if the value is 2545 it is coming 2545 but i need an output like this .
2545.00 .what to do ?
regards,
mani
‎2007 Oct 04 1:34 PM
Hi
declare a variable like this
data v_val type NETWR.
move the value to this field
Move number to v_val.
now v_val have 2 decimals
Regards
anji
‎2007 Oct 04 1:37 PM
HI,
If you delcare the field like <b>type p decimals 2.</b> then you won;t get the .00 decimals, you need to take the SAP Predefined value to get these values
Regards
Sudheer
‎2007 Oct 04 1:55 PM
Hi,
declare tour variable as
data var type p decimals 2.
var1 = '4567.5'.
var = var1.
write var.
var will have 4567.50.
Regards,
Amole
‎2007 Oct 04 2:28 PM
Hi Amole,
I did not believe so I tried:
data: var type p decimals 2,
var1 type text40.
var1 = '4567.5'.
var = var1.
write var.
... and what do I get?
456,75
Type P is packed decimal. The number of decimals wll be interpreted when calculations, output or input from screen field is done.
MOVE (= is move) will just move ignoring the decimal point.
You can solve the issue:
DATA: var TYPE p DECIMALS 2,
var1 TYPE text40,
decimals TYPE i.
var1 = '4567.5'.
f = var1.
DESCRIBE FIELD var DECIMALS decimals.
WHILE decimals > 0.
f = f * 10.
SUBTRACT 1 FROM decimals.
ENDWHILE.
var = f.
WRITE var.
Regards,
Clemens