2008 Sep 23 9:44 AM
Hi Gurus
need help, i have a requirement for computing in vat ,in calculator it seems correct but in abap the result is different. this weird scenario i encountered.
all variables are in type p decimals 2.
netwr = 249.38
kbetr = 50.00
i try 2 approach.
vat = (netwr * ( kbetr / 1000))
and
tmp_var = kbetr / 1000.
vat = netwr * tmp_var
the result is vat = 1246.90
but in calculator or in excel is 12.469
any idea? thanks
2008 Sep 23 9:48 AM
Hi,
Check whether the fixed point arithmetic is checked or not. This makes lot of difference. To check this Goto Attributes of your report, a pop up window appears. Here you have that checkbox Fixed Point Arithmetic. Check it, Save and Close.
Regards,
Swapna.
Hi
thanks to all it solve my problem, the bottom problem is FIX POINT ARITHMETIC though i have also the right formula and all of you. I love this forum...
hope you got all your points
2008 Sep 23 9:47 AM
Hi..
It is with the decimal declaration I suppose.. Could you try declaring it with p decimal 1 instead of 2 and check if ur getting the same result.
Regards,
Vishwa.
2008 Sep 23 9:48 AM
Hi,
Check whether the fixed point arithmetic is checked or not. This makes lot of difference. To check this Goto Attributes of your report, a pop up window appears. Here you have that checkbox Fixed Point Arithmetic. Check it, Save and Close.
Regards,
Swapna.
2008 Sep 23 9:48 AM
hi,
two things:
1. pls. check if Fixed point arithmetic is ticked in Program Attributes
2. Always multiply first and divide later for higher accuracy.
hope this helps
ec
2008 Sep 23 9:48 AM
hii
I think the problem is with the declaration... Just try the same calculation by declaring it with p decimal 1 instead of 2.
Regards,
Vishwa.
2008 Sep 23 9:49 AM
Please check if the 'Fixed point arithmetic' check box is ticked in the attributes of your program.
2008 Sep 23 9:49 AM
Check below code....
data: v_kbetr type p decimals 2,
v_netwr type p decimals 2,
v_temp type p decimals 3.
v_netwr = '249.38'.
v_kbetr = '50.00'.
v_temp = v_kbetr / 1000.
v_temp = v_temp * v_netwr.
write:/ v_temp.
Output is 12.469
2008 Sep 23 9:51 AM
2008 Sep 23 9:51 AM
Hi,
The below code is working fine
data: vat type p decimals 2,
netwr type p decimals 2,
kbetr type p decimals 2.
netwr = '249.38'.
kbetr = '50.00'.
vat = ( netwr * ( kbetr / 1000 ) ).
write : vat.
Output is 12.47
Regards,
Surinder
2008 Sep 23 9:51 AM
IF your target field is of type P decimals 2 then it is coming 12.47, right result...............
2008 Sep 23 9:56 AM
Hi,
I have executed your code and made some chnages it is working fine copy paste the code and check
DATA: NETWR TYPE P VALUE '249.38',
KBETR TYPE P VALUE '50.00',
VAT TYPE P DECIMALS 3.
VAT = ( NETWR * ( KBETR / 1000 ) ).
WRITE: VAT.
VAT = 12.450
Hope this helps you.
Cheers!!
2008 Sep 23 10:02 AM
Hi,
Plz write the code this way it works try :
data: vat type p decimals 3,
netwr type p decimals 2,
kbetr type p decimals 2,
tmp_var type p decimals 2.
netwr = '249.38'.
kbetr = '50.00'.
tmp_var = kbetr / 1000.
vat = ( netwr * tmp_var ).
vat = netwr * tmp_var.
write: vat.o/p : 12.469.
thanx.
2008 Sep 23 11:02 AM
Hi
thanks to all it solve my problem, the bottom problem is FIX POINT ARITHMETIC though i have also the right formula and all of you. I love this forum...
hope you got all your points
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |