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 when doing mathematical operation

0 Likes
866

Hello Everyone,

Am faced with a problem when dividing two values.

The numerator is field vbrp-cmpre, Domain: WERTV6, Value: 139.20

The denominator is field vbrp-fkimg, Domain: MENG13, Value: 5.000

Am taking the result into a variable LIKE vbrp-cmpre. The value I am getting is 0.03, which is incorrect.

I understand that this may be a conversion problem. Could someone please explain how to solve this?

Thank you very much.

Regards,

Johnson

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
819

See if the attribute for Fixed Point- Arithmetic is checked in your program.

se38.

Give Program name.

Choose Attributes radio-button.

Click Display.

Regards,

Ravi

5 REPLIES 5
Read only

Former Member
0 Likes
820

See if the attribute for Fixed Point- Arithmetic is checked in your program.

se38.

Give Program name.

Choose Attributes radio-button.

Click Display.

Regards,

Ravi

Read only

Former Member
0 Likes
819

Hello Johnson,

I don't think this is with the Conversion problem.

Declare variable where u r storing the result as <b>PACKED NUMBER

DATA: RESULT TYPE P DECIMALS 2.</b>

Reward if helps.

Vasanth

Read only

Former Member
0 Likes
819

its because in the program attributes, the Check box FIXED POINT ARITHMETIC field is not selected.

because of this you are getting 0.03

if you select that and do that you will get 27.84.

Regards

Srikanth

Read only

Former Member
0 Likes
819

HI,

I drafted a sample code as follows and executed:

data: a1 like vbrp-cmpre value '139.20',

a2 like vbrp-fkimg value '5.000'.

data: a3 like vbrp-cmpre.

a3 = a1 / a2.

write:/ a1,

/ a2,

/ a3.

I get the result:

139.20

5.000

27.84

I don't think there's any conversion problem. Pls check ur code.

Regards

Subbu

Read only

Former Member
0 Likes
819

Hi,

Immaterial of whether the fixed point arithmetic is ON or NOT, you are bound to get a truncated value in the sum because you are target field can hold only 2 decimals. So, the denomenator will be rounded off to 2 decimals value.

First thing is you have to check 'FIXED POINT ARITHMETIC' on the attributes of the program, and then you have to choose your target field after division to refer a domain having 3 decimal places so that any truncation can be avoided.

data : l_tot type vbrp-cmpre value '139.20'.

data : l_den type vbrp-fkimg value '5.010'.

data : l_fin type vbrp-fkimg.

l_fin = l_tot / l_den.

write: l_fin.