Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Calculation when Fixed point arithmetic not selected

Former Member
0 Likes
1,432

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>

It’s 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.

1 ACCEPTED SOLUTION
Read only

Former Member
983

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.

3 REPLIES 3
Read only

Former Member
0 Likes
983

Hi,

Could you please give me some helpful hints?

Regards,

Balaji Viswanath.

Read only

rainer_hbenthal
Active Contributor
0 Likes
983

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

Read only

Former Member
984

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.