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

Same calculation producing two differing results

Former Member
0 Likes
1,036

Hi All

I have some code in a user exit on save of a delivery (VL02N) that calculates the number of bags/pallets required to furnish that delivery.

I am now adding the same code to a user exit on save a sales order (VA02) to calculate the number of bags/pallets again but when run it is producing differing results.

the code is as follows:


DATA: bag_weight(12) TYPE p DECIMALS 4.
DATA: pallet_weight TYPE marm-umrez.
DATA: bag_denominator TYPE i.

...

bag_weight = pallet_weight / bag_denominator.

Assuming pallet_weight = 1000 and bag_denominator = 40.

On save of a delivery it is calculating bag_weight as 25.0000 (correct):

On save of a sales order it is calculating bag_weight as 0.0025 (incoorect).

All data declaration, code etc is the same. Does anybody have any clue as to why it would give two differing answers, I would not like to have to add a additional multiplication step to correct the result otherwise.

Thanks in advance

David

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
979

Hi ,

Would you please check whether Fixed Point Arithmetic is checked or not in the program attributes.

Some times if the Unicode and Fixed Point Arithmetic is not checked , creates prolem .

Regards

Pinaki

8 REPLIES 8
Read only

Former Member
0 Likes
979

why dont u just keep a break point and check??

Read only

Former Member
0 Likes
979

Check whether the weight unit field ( GEWEI ) is same or different in sales order and Delivery.

Read only

SimoneMilesi
Active Contributor
0 Likes
979

The weight unit (e.g. KG, G, etc) are the same?

Seems a conversion problem to me.

If they are not the same, you can use the FM UNIT_CONVERSION_SIMPLE to convert everything into the same unit.

If you need to have something equal to compare, i suggest you to implement this FM anyway.

Read only

Former Member
0 Likes
979

David,

Are the interfaces into the User Exit the same?

Cheers,

Neil.

Read only

Former Member
0 Likes
981

Hi ,

Would you please check whether Fixed Point Arithmetic is checked or not in the program attributes.

Some times if the Unicode and Fixed Point Arithmetic is not checked , creates prolem .

Regards

Pinaki

Read only

Former Member
0 Likes
979

Hi,

Whenever you are using the Packed numbers, you need to check or set the program attribute fixed point arithmetic only as only this ensure that the decimal point is calculated correctly.

Have a look at the help.sap.com documentation link:

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2fd9358411d1829f0000e829fbfe/content.htm

Hope this helps.

Thanks,

Samantak.

Read only

Former Member
0 Likes
979

Hi,

Please check whether the FIXED POINT ARITHMETIC attributes is set for your program in the program attributes.

Regards,

Ankur Parab

Read only

Former Member
0 Likes
979

Please check the units of the pallet weight while creating the sales order.