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

decimal issue when dividing

Former Member
0 Likes
1,135

Hi ,

price is in curr with 2 decimals, while qty is in data type DEC, 5.

cal = ( price / qty )

i want to get the calc in 3 decimal points.

when i put calc as p decimal 3 it gave a different value.

Eg, 58.467/10 gave as 0.585 where as it should be 5.847

Can any one advise as to which data type i should use for calc field.

Thanks

Keshi

2 REPLIES 2
Read only

Former Member
0 Likes
842

data : l_price type bseg-dmbtr,

l_qty type p decimals 5,

l_cal type p decimals 3.

l_price = '58.467'.

l_qty = 10.

l_cal = l_price / l_qty .

WRITE 😕 l_cal.

Read only

Former Member
0 Likes
842

Hi,

the problem is with the <b>attribute of the program</b> where your are writing the code for division.

open the prog in SE38 and check the <b>Fixed point arithmetic</b> parameter - i guess u ll find it dechecked. To get proper result <b>u need to have it checked</b>.

if you are inside a customer exit/include then you will have to create a function module for doing the calculations and related stuffs.

hope it solves ur prob.