‎2009 May 04 8:23 AM
hello all,
in a customize abap program i am multiplying two fields and storing them in another variable
those two fields are vbrk-netwr(data type - curr , length 15 decimals 2) and
vbrk-kurrf (data type- dec , length 9 decimals 5).
i have declared my variables in following way:
tables: vbrk.
data: begin of itab occurs 0,
vbeln TYPE vbrk-vbeln,
kurrf like vbrk-kurrf,
netwr like vbrk-netwr,
x like vbrk-netwr,
end of itab.
start-of-selection.
SELECT vbeln kurrf netwr
FROM vbrk
INTO TABLE itab.
loop at itab.
itab-x = itab-netwr * itab-kurrf.
MODIFY itab.
ENDLOOP.
end-of-selection.
loop at itab.
write:/ itab-vbeln,
itab-netwr ,
itab-kurrf,
itab-x,
endloop.
all the values are coming ok except itab-x. for eg.
90006752 vbeln
340,000.00 netwr
1.00000 kurrf
34,000,000,000.00 x (wrong should be 340,000.00)
90005531 vbeln
1 00,000.00 netwr
62.15000 kurrf
621,500,000,000.00 x (wrong shoul be 6215000.00)
regards
pankaj
‎2009 May 04 8:38 AM
Hi Pankaj,
ITAB-X is a type of VBRK-NETWR,,,
it dosent stiore more than 2 decimal points...
please change that one to itab-x type p decimals 5.
thats it .. if still problem exits change ITAB-X to char..
Thanks & regards,
Dileep .C
‎2009 May 04 8:39 AM
Pankaj,
As far as I know, the problem is with the decimal point multiplication. As you are multiplication the variables having different decimal notation, this could be the problem.
Try to type cast it in to a temporary variable of same type before multipling it and check the result.
I am not sure whether that would work. But, thot of giving a pointer.
Thanks,
Babu Kilari
‎2009 May 04 9:26 AM
Hi,
Use all the variables having same type, then you will get the result what u want
‎2009 May 04 9:31 AM
‎2009 May 04 9:50 AM
hi,
try the below code which might help u :-
report ZNEW32." NO STANDARD PAGE HEADING
" LINE-SIZE 80
" LINE-COUNT 65.
tables: vbrk.
data: begin of itab occurs 0,
vbeln TYPE vbrk-vbeln,
kurrf like vbrk-kurrf,
netwr like vbrk-netwr,
x like vbrk-netwr,
y(16) TYPE p DECIMALS 2,
end of itab.
start-of-selection.
SELECT vbeln kurrf netwr
FROM vbrk UP TO 10 ROWS
INTO TABLE itab.
loop at itab.
itab-x = itab-netwr * itab-kurrf.
itab-y = itab-x.
MODIFY itab.
ENDLOOP.
end-of-selection.
loop at itab.
write:/ itab-vbeln,
itab-netwr ,
itab-kurrf,
itab-x,
itab-y.
endloop.
OUTPUT:-
400000 21,195.05 1.00000 21,195.05 21,195.05
400001 37,395.09 1.00000 37,395.09 37,395.09
400002 21,195.05 1.00000 21,195.05 21,195.05
400003 37,395.09 1.00000 37,395.09 37,395.09
400004 76,477.68 1.00000 76,477.68 76,477.68
400005 91,158.12 1.00000 91,158.12 91,158.12
400006 101,894.37 1.00000 101,894.37 101,894.37
400007 45,022.60 1.00000 45,022.60 45,022.60
400008 68,418.60 1.00000 68,418.60 68,418.60
400009 58,749.31 1.00000 58,749.31 58,749.31
revert back if it useful for u or not.
Edited by: ricx .s on May 4, 2009 10:51 AM
Edited by: ricx .s on May 4, 2009 10:59 AM
‎2009 May 04 10:12 AM
hi ricx ,
when i m executing ur code see thae value of itab-x and itab-y.
multiplication problem still exists.
53000001 1,500.00 39.40000 5,910,000,000.00 5,910,000,000.00
53000002 483.00 33.35000 1,610,805,000.00 1,610,805,000.00
53000003 22,320.00 1.00000 2,232,000,000.00 2,232,000,000.00
53000004 52,098.00 1.00000 5,209,800,000.00 5,209,800,000.00
53000005 207,142.50 1.00000 20,714,250,000.00 20,714,250,000.00
53000006 7,000.00 1.00000 700,000,000.00 700,000,000.00
53000007 224,850.00 1.00000 22,485,000,000.00 22,485,000,000.00
53000008 11,635.34 1.00000 1,163,534,000.00 1,163,534,000.00
53000009 510.00 1.00000 51,000,000.00 51,000,000.00
53000010 17,680.00 1.00000 1,768,000,000.00 1,768,000,000.00
‎2009 May 04 10:36 AM
Hi Pankaj,
I have a good news for you,
None of the above code will work,,,!
Since your original code is perfect. I just now copied & executed your code,
its working fine for me. I am using 4.7 EE
just check with your settings once again,,,
Thanks & regards,
Dileep .C
‎2009 May 04 10:38 AM
hi dileep,
i m using ecc6.0 version ,
from where i will check the setting
regards
pankaj
‎2009 May 05 2:53 AM
Hi Pankaj,
I am not sure but.
Please check Decimal notation in defaults in SU01 Tcode.
Also do some other calculations.. apart from your requirement.. and do ask you friends in office to run your code,, is their settings are correct.
Thanks & regards,
Dileep .C
‎2009 May 04 9:38 AM
Use x field as character field shown below..
data: begin of itab occurs 0,
vbeln TYPE vbrk-vbeln,
kurrf like vbrk-kurrf,
netwr like vbrk-netwr,
x(15) TYPE c,
end of itab.
Hope it will solve ur problem...i tried, it working...
‎2009 May 04 9:49 AM
hi mujib,
my data is not coming correct.
90006752 vbeln
340,000.00 netwr
1.00000 kurrf
34,000,000,000.00 it is wrong
right value should be 340,000.00
regards
pankaj
‎2009 May 04 9:59 AM
hi pankaj,
I tried it at my end using ur 'X' field as character type. it works...
for eg-
93098129 497,303.64 1.00000 497303.64
93098130 506,437.80 1.00000 506437.8
93098131 425,245.36 1.00000 425245.36
93098132 497,811.10 1.00000 497811.1
93098133 465,841.58 1.00000 465841.58
90238836 2,210.00 1.00000 2210
94814635 3.00 39.85000 119.55
90238837 686.52 1.00000 686.52
90238838 2,553,854.40 1.00000 2553854.4
90238839 2,343,321.60 1.00000 2343321.6
90238840 2,305,563.00 1.00000 2305563
90238841 2,156,817.00 1.00000 2156817
90238842 114,420.00 1.00000 114420
90238843 194,514.00 1.00000 194514
90238844 114,420.00 1.00000 114420
90238845 57,210.00 1.00000 57210
90238846 252,575.00 1.00000 252575
‎2009 May 05 5:15 AM
Yaar I get the same problems when i use NETWR, i don't know why. So another way i fixed this problem is devide the result by 10000 I know it's not a perfect solution but still.
loop at itab.
itab-x = itab-netwr * itab-kurrf / 10000.
MODIFY itab.
ENDLOOP.
Hey i copied and ran ur program and its running perfect, no need to change anything. i don't know why ur system is behaving that way.
Result:
test
90000000 404,916.62 1.00000 404,916.62
90000001 10,243.96 1.00000 10,243.96
90000002 309,922.54 1.00000 309,922.54
90000003 259,529.70 1.00000 259,529.70
90000004 10,243.96 1.00000 10,243.96
90000005 20,487.92 1.00000 20,487.92
90000006 10,243.96 1.00000 10,243.96
90000007 7,202.96 1.00000 7,202.96
90000008 5,503.89 1.00000 5,503.89
90000009 601,100.20 1.00000 601,100.20
Edited by: Tripat Pal Singh on May 5, 2009 9:48 AM
Edited by: Tripat Pal Singh on May 5, 2009 9:49 AM
‎2009 May 05 8:19 AM
hi all
thanks all of u for your useful contributions:
the problem has been resolved.
by checking the fixed-point arithmetic checkbox in attribute section of se38.
regards
pankaj