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

MARM Conversion Result Drops Decimal?

Former Member
0 Likes
1,303

A new Material conversion was created in MM02 for a Karton....'KAR'. The conversion is KG to KAR.

The original ABAP logic was zresult = 102 / 5. This should equal 20.4:

The code used

marm-umrez = marm-umrez / marm-umren

the result is 20, missing decimal value.

I understand that umrez and umren are not decimals so a decimal cannot be assigned to the result so I tried this:

DATA: znew_value(5) type p DECIMALS 3. 
DATA: umrez_new(5) type p DECIMALS 2.
DATA: umren_new(5) type p DECIMALS 2.

umrez_new = marm-umrez .
umren_new = marm-umren.
znew_value = umrez_new / umren_new.

I still get 20 instead of 20.4?

I have played with the syntax unpack, write to, assign to, and move to, but my syntax cold have been off.

Can anyone suggest how I can use, or define a new field, or fields to pass them into so that I will get the decimal value after the calculation? Or, possible syntax for calculating the result using the original fields that will have the decimal value.

Thank-You

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
915

Hi Tom,

This issue drove me nuts once before. In your program look at the attributes. Make sure the checkbox is checked for Fixed point arithmetic.

Brenda

A new Material conversion was created in MM02 for a Karton....'KAR'. The conversion is KG to KAR.

The original ABAP logic was zresult = 102 / 5. This should equal 20.4:

The code used

marm-umrez = marm-umrez / marm-umren

the result is 20, missing decimal value.

I understand that umrez and umren are not decimals so a decimal cannot be assigned to the result so I tried this:

DATA: znew_value(5) type p DECIMALS 3. 
DATA: umrez_new(5) type p DECIMALS 2.
DATA: umren_new(5) type p DECIMALS 2.

umrez_new = marm-umrez .
umren_new = marm-umren.
znew_value = umrez_new / umren_new.

I still get 20 instead of 20.4?

I have played with the syntax unpack, write to, assign to, and move to, but my syntax cold have been off.

Can anyone suggest how I can use, or define a new field, or fields to pass them into so that I will get the decimal value after the calculation? Or, possible syntax for calculating the result using the original fields that will have the decimal value.

Thank-You

3 REPLIES 3
Read only

naimesh_patel
Active Contributor
0 Likes
915

Looks like Fixed point Arithmetic is not set in the Program Attributes. If you code is in the User Exit, most probably the std SAP program would have it switched off. You should create a FM to do the calculation and bring the values back to the user exit.

Regards,

Naimesh Patel

Read only

Subhankar
Active Contributor
0 Likes
915

Hi,

From ur code, I written the below code.

DATA: znew_value(5) type p DECIMALS 3.

DATA: umrez_new(5) type p DECIMALS 2.

DATA: umren_new(5) type p DECIMALS 2.

DATA: marm TYPE marm.

marm-umrez = 102.

marm-umren = 5.

umrez_new = marm-umrez .

umren_new = marm-umren.

znew_value = umrez_new / umren_new.

BREAK-POINT.

Its giving the perfect result.

Can you try this one in a test program. If this one is working in SE38 program then its a arithmetic problem of any routine. 😛

To overcome this one you have to write one small FM and build the logic there. Its a magic

Regards

Subhankar

Edited by: Subhankar Garani on Oct 27, 2011 7:11 PM

Read only

Former Member
0 Likes
916

Hi Tom,

This issue drove me nuts once before. In your program look at the attributes. Make sure the checkbox is checked for Fixed point arithmetic.

Brenda