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: 

ABAP calculating in Include MV45AFZZ

Former Member
0 Kudos

Hej.

I am experiencing strange things with this bit of code. This code is taking place in FORM userexit_save_document_prepare in include MV45AFZZ.

And the result of the calculation is wrong, when I take the code and try it out in a new program, then i get a different results.

Here is the example.

xkomv-KWERT = 3.5

xkomv-KUMNE = 1000.

xkomv-KUMZA = 1000.

The result in the l_pris_pr_kg is : 1.8272945598830532E+01 But should be : 1.8272945598830531E-01

DATA: BEGIN OF xpreis OCCURS 20,

posnr TYPE kposn,

preis TYPE bapre,

DATA: END OF xpreis.

DATA: l_pris_pr_kg TYPE f.

LOOP AT xkomv WHERE kschl = 'ZMKP'. "

xpreis-posnr = xkomv-kposn.

l_pris_pr_kg = ( xkomv-KWERT * xkomv-KUMNE ) / xkomv-KUMZA.

xpreis-preis = l_pris_pr_kg.

APPEND xpreis.

ENDLOOP.

I have also tryed to put this into a STRING where in the Include MV45AFZZ I get the result

String = 18,

but in my test program i get the result

String = 0.18272945598831 (Which is correct).

So it seems that in this include I cannot get this to work correctly.

Is there anyone that has experienced something similiar, all help would be appreciated.

Thanks Gisli

1 ACCEPTED SOLUTION

former_member555112
Active Contributor
0 Kudos

HI,

Just check if teh fixed poitn arithmetic flag is set in the attributes of the program.

Regards,

Ankur Parab

4 REPLIES 4

former_member555112
Active Contributor
0 Kudos

HI,

Just check if teh fixed poitn arithmetic flag is set in the attributes of the program.

Regards,

Ankur Parab

0 Kudos

Hi Ankur,

The problem lokks similar But, MV45AFZZ is a Standard include,

No Fixed point Arthematic Available,,,

Hi Gisli,

Try to divide i_pris_pr_kg by 100... Hope this could solve your problem...

Thanks & regards,

Dileep .C

Former Member
0 Kudos

Hello,

in SAPMV45A - which is the main program to this includes like MV45AF.. - there's no fixpoint-arithmetic active ! But if you create an own program, normally this flag is active by default.

So, you could write your logic in MV45AFZZ according to the digits that you have in your fields.

Practically you could divide the i_pris_pr_kg by 100.

Regards Wolfgang

Former Member
0 Kudos

Thank you very much, your comments explained my problem.

Best regards Gisli