Application Development 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: 

Calculation Error

former_member220801
Participant
0 Kudos

I have two field

a LIKE MBEWH-LKBUM (QUAN 13)

b LIKE MBEWH-VERPR (CURR 11)

When I multiply them together

e.g. a = 10.000, b = 50.00

It gives 500000.00 rather than 500.00

I don't know why and can't figure out what's the problem. Please help. Thanks!

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

In your program, do you have "Fixed point arithmatic" checked in the program attributes? click goto -> attributes. Check the box for it and run it again.

I just check it in my system. I do think that this is your problem. Please make sure that you check that box in the program attributes.

report zrich_0001
       no standard page heading.

data:
a type mbew-lbkum value '10.000',
b type mbew-verpr value '50.000'.

data: result type mbewh-lbkum.


result = a * b.

write:/ result.

Please reward points and mark your post as solved. Thanks.

Regards,

Rich Heilman

Message was edited by: Rich Heilman

5 REPLIES 5

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

In your program, do you have "Fixed point arithmatic" checked in the program attributes? click goto -> attributes. Check the box for it and run it again.

I just check it in my system. I do think that this is your problem. Please make sure that you check that box in the program attributes.

report zrich_0001
       no standard page heading.

data:
a type mbew-lbkum value '10.000',
b type mbew-verpr value '50.000'.

data: result type mbewh-lbkum.


result = a * b.

write:/ result.

Please reward points and mark your post as solved. Thanks.

Regards,

Rich Heilman

Message was edited by: Rich Heilman

0 Kudos

I agree with Rich, check the attribute "Fixed point arithmatic" of your program.

Max

manuel_bassani
Contributor
0 Kudos

Hi Gundam,

i tried this code:


data:a LIKE MBEWH-LBKUM,
     b LIKE MBEWH-VERPR.

a = '10.000'.
b = '50.00'.

a = a * b.

a now is 500.000

try to check the the type of result variable.

It may be caused by it.

Regards, Manuel

Former Member
0 Kudos

Hi Gundan,

The currency field behaviour is little confusing in SAP. Every amount field has reference field for the currency in which amount is being represented. Though the field might see to contain 500000, but if you use write statement with currency clause ( write MBEWH-VERPR currency T001-WAERS ), it will give you the correct amount.

The reson behind this that every currency has fixed number of decimal places ( table TCURX , currecies not in this table are assumed to have 2). The amount in the currency field is devided by ( 10 power number of decimal places in currency). Therefore, for USD, the amount will be devided by 100.

Former Member
0 Kudos

Are you doing this calculation in some kind of user exit? If so, check the attributes of the main program of this transaction as suggested by others here. It is not the attribute of the include in which you are writing the user exit code.

If it an user exit that you are doing this in, then you need to manually do the divisions.

Srinivas