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

Problem with fixed point arithmetic

Former Member
0 Likes
1,281

HI guys,

fixed point arithemtic in my program is unticked and I want it that way. But I have a question on what's the explanation behind this issue

v_netprice like LIPS-NETPR

v_net value like bapiitemin-req_qty

v_qty type lips-lgmng

v_net_value = 436927.2000

v_qty = 240.000

v_netprice = v_net_value / v_qty.

In v_netprice, I am getting 1.8205... Why is this so?

Thanks a lot!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,065

Hi Mark,

If you mark this checkbox, *all caluculations in the program will use fixed point arithmetic

If you do not, packed numbers (ABAP/4 type P, Dictionary types CURR, DEC or QUAN) will be treated as integers when they are used in assignments, comparisons and calculations, irrespective of the number of decimal places defined. Intermediate results in arithmetic calculations will also be rounded to the next whole number. The number of decimal places defined is only taken into account when you output the answer using the WRITE statement.

Regards,

Swapna.

6 REPLIES 6
Read only

Former Member
0 Likes
1,065

Hi,

Check fixed point arithmetic option F1 help.

goto->attributes-> fixed point arithmetic

press F1.

Regards

Adil

Read only

Former Member
0 Likes
1,065

Please declare v_netprice as a packed number.

Thanks and Regards ,

Debojyoti.

Read only

Former Member
0 Likes
1,065

hi Mark,

I have tried the below code on my system and i am getting the value correctly ...


data : v_netprice type NETPR,
v_net_value type NETPR,
v_qty type lips-lgmng.

v_net_value = '436927.2000'.
v_qty = '240.000'.

v_netprice = v_net_value / v_qty.

write : v_netprice.

Read only

Former Member
0 Likes
1,065

hiii

just set from menu->goto->attributes->mark checkbox fixed point arithmetic..it will give you a correct answer

regards

twinkal

Read only

Former Member
0 Likes
1,065

look at the field description for field bapiitemin-req_qty

'Order qty in sales units - 00009001 corresponds to 9.001'

Might be U got the result as .. 1820.5.. but it is showing as

1.8205 ..

Read only

Former Member
0 Likes
1,066

Hi Mark,

If you mark this checkbox, *all caluculations in the program will use fixed point arithmetic

If you do not, packed numbers (ABAP/4 type P, Dictionary types CURR, DEC or QUAN) will be treated as integers when they are used in assignments, comparisons and calculations, irrespective of the number of decimal places defined. Intermediate results in arithmetic calculations will also be rounded to the next whole number. The number of decimal places defined is only taken into account when you output the answer using the WRITE statement.

Regards,

Swapna.