‎2007 Oct 16 2:51 PM
Hi,
I have written a pricing formula routine (RV64A*) since routine resides inside SAPLV61A and Fixed point arithmetic is not selected, pricing formula routine also inherits the properties i.e. fixed point arithmetic is not selected so while doing any calculation I am taking care of decimals and doing the calculation accordingly.
<b>DATA: v_zrus_price TYPE p DECIMALS 3,
v_zrus_manual_price TYPE p DECIMALS 3,
v_zrus_factor TYPE p DECIMALS 10,
v_kbetr TYPE kbetr.
v_kbetr = '2235.60'.
v_zrus_manual_price = '1209.000'.
v_zrus_price = '1106.235'.
v_zrus_factor = ( ( ( ( v_kbetr / 10 ) - ( v_zrus_manual_price / 100 ) ) * 1000000000000 ) / ( v_zrus_price ) ).
write:/ v_zrus_factor.</b>
As expected above calculation written the value <b>0.9280125832</b>.
But same calculation is not working when I assign
<b>v_kbetr = '199123.24'.
v_zrus_factor = ( ( ( ( v_kbetr / 10 ) - ( v_zrus_manual_price / 100 ) ) * 1000000000000 ) / ( v_zrus_price ) ).
write:/ v_zrus_factor.</b>
Its returning the value <b>178.9079173955</b> instead of expected <b>178.9079535542</b>.
Could you please tell me what is the mistake and how to correct it?
Thanks in advance.
Regards,
Balaji Viswanath.
‎2007 Oct 17 2:41 AM
quick work around for this is:
create a function module and do all the calculations there. pass the results back to the program. I have done the same in our recent project.
‎2007 Oct 16 3:11 PM
Hi,
Could you please give me some helpful hints?
Regards,
Balaji Viswanath.
‎2007 Oct 16 3:52 PM
One of your intermediate results is getting too big, truncating some digits at the end. the follwoing formular avoids this:
a/10 - b/100 is the the same as (10a-b)/100 and now you can shorten the 100 with the 1000000000000 giving
v_zrus_factor = ( ( ( ( 10 * v_kbetr ) - ( v_zrus_manual_price ) ) * 10000000000 ) / ( v_zrus_price ) ).Message was edited by:
Rainer Hübenthal
‎2007 Oct 17 2:41 AM
quick work around for this is:
create a function module and do all the calculations there. pass the results back to the program. I have done the same in our recent project.