‎2007 Jun 06 11:12 PM
I have three data objects
mglme length 13, decimal 3 type quan
kbetr length 11, decimal 2 type curr
netwr length 15, decimal 2 type curr
I need to do kbetr = netwr / mglme
But I never get the right value because of the difference in data lengths
for e.g. netwr = 150.00 and mglme = 10.000 returns kbetr = .015
Any help on how to solve this. Thanks
‎2007 Jun 07 1:00 AM
I have three data objects
mglme length 13, decimal 3 type quan
kbetr length 11, decimal 2 type curr
netwr length 15, decimal 2 type curr
declare three variables temporary.
data : lv_kbetr like vbak-netwr.
data : lv_mglme like vbak-netwr.
data : lv_netwr like vbak-netwr.
clear : lv_kbetr,
lv_mglme,
lv_netwr.
move : kbetr to lv_kbetr,
mglme to lv_mglme,
netwr to lv_netwr.
lv_kbetr = lv_netwr / lv_mglme.
move lv_kbetr to kbetr.
Now see the results.
‎2007 Jun 06 11:44 PM
‎2007 Jun 07 1:00 AM
I have three data objects
mglme length 13, decimal 3 type quan
kbetr length 11, decimal 2 type curr
netwr length 15, decimal 2 type curr
declare three variables temporary.
data : lv_kbetr like vbak-netwr.
data : lv_mglme like vbak-netwr.
data : lv_netwr like vbak-netwr.
clear : lv_kbetr,
lv_mglme,
lv_netwr.
move : kbetr to lv_kbetr,
mglme to lv_mglme,
netwr to lv_netwr.
lv_kbetr = lv_netwr / lv_mglme.
move lv_kbetr to kbetr.
Now see the results.
‎2007 Jun 07 2:15 AM
data : var1 type p decimals 3,
var2 type p decimals 2.
curr and quan are database data type so you can not reffer them in your abap program the abap type is type p.
regards
shiba dutta
‎2007 Jun 07 2:45 AM
I don't believe this is happening becasue of the differences in the data lengths. I think it is because you are dealing with currency fields without referencing the involved currency. Some currencies, eg japanese yen, don't have decimal places, for all I know some may have more than 2. SAP gets round this by defining the attributes of each currency. The currency related variables can only be adjusted to the appropriate number of decimal places when they refer to the currency involved. If no currency reference is provided how can SAP work out how many decimal places you want to work with?
FOR EXAMPLE, create this simple program and you'll see what I mean.
REPORT ZNRW_CURRENCY .
parameters: P_curr1 type t001-waers default 'JPY',
p_curr2 type t001-waers default 'USD'.
DATA W_VALUE TYPE marc-VKUMC VALUE 1.
WRITE:/ W_VALUE CURRENCY P_CURR1,P_CURR1.
WRITE:/ W_VALUE CURRENCY P_CURR2,P_CURR2.