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

incorrect arithmetic calculation in user exit MV45AFZZ

former_member431874
Participant
0 Likes
1,976

In the user exit MV45AFZZ, when dividing a figure, I always get an incorrect result.

For example, 75.00 / 1.500 = 0.05 << it should be 50

here is my code (simplified for testing):

DATA: wa type vbap.

SELECT *

FROM vbap

INTO corresponding fields of wa

WHERE VBELN = '...' and

POSNR = '...'.

wa-NETWR = wa-NETWR / wa-KWMENG. <-- 75.00 / 1.500 = 0.05

wa-CMPRE = wa-CMPRE / wa-KWMENG. <-- 53.50 / 1.500 = 0.04

ENDSELECT.

If I copy the same code to a ZProgram, I get a correct result.

Would you please tell me what's wrong and how to solve the problem in the user exit MV45AFZZ?

In the user exit MV45AFZZ, when dividing a figure, I always get an incorrect result.

For example, 75.00 / 1.500 = 0.05 << it should be 50

here is my code (simplified for testing):

DATA: wa type vbap.

SELECT *

FROM vbap

INTO corresponding fields of wa

WHERE VBELN = '...' and

POSNR = '...'.

wa-NETWR = wa-NETWR / wa-KWMENG. <-- 75.00 / 1.500 = 0.05

wa-CMPRE = wa-CMPRE / wa-KWMENG. <-- 53.50 / 1.500 = 0.04

ENDSELECT.

If I copy the same code to a ZProgram, I get a correct result.

Would you please tell me what's wrong and how to solve the problem in the user exit MV45AFZZ?

5 REPLIES 5
Read only

kerem_kayacan
Active Participant
0 Likes
1,452

I think main program's "Fixed Point Arithmetic" attribute is unchecked. You can use a custom function module to make the calculation.

Read only

0 Likes
1,452

>

> I think main program's "Fixed Point Arithmetic" attribute is unchecked. You can use a custom function module to make the calculation.

Can I check the "Fixed Point Arithmetic" attribute? Will it solve the problem?

Read only

0 Likes
1,452

The main program must be SAP standard program, so it will take a repair to do this. Besides, it can effect any other part of the program. So developing a little function module according to your need will be a better idea.

Read only

Sridharnekkanti
Active Participant
0 Likes
1,452

Try with this

wa-NETWR = ( wa-NETWR / ( wa-KWMENG * 1000 )) *1000

wa-CMPRE = ( wa-CMPRE / ( wa-KWMENG * 1000))* 1000

Read only

former_member431874
Participant
0 Likes
1,452

Dear Kerem Kayacan,

I'll try to create the FM, and award more points if it works.

Dear Sridhar N,

Your formula works if it's in a ZProgram; however, it still doesn't work when it's in the user exit. The result I get is 0.00