cancel
Showing results for 
Search instead for 
Did you mean: 

Currency divided by quantity

balaji_viswanath
Participant
0 Kudos

Hi,

I am trying to divide a currency field with quantity field and want to store the result in currency field or decimal field. I tried it as below...

DATA: l_field1 LIKE J_1IEXCDTL-EXBAS,

l_field2 LIKE j_1iexcdtl-menge,

l_field3 TYPE p DECIMALS 2.

l_field1 = ' 165915.00'.

l_field2 = ' 15.000'.

l_field3 = l_field1 / l_field2.

WRITE 😕 l_field3.

I am getting the desired result (output is comming as 11061.00).

But same thing is not working, output is comming as 11.06 for below code...

l_field3 = it_excdtl-exbas / it_excdtl-menge.

Why? How to solve it.

Advance thanks.

Regards,

Balaji Viswanath.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

More details would help.

Is it_excdtl-exbas defined the same as J_1IEXCDTL-EXBAS? Likewise for it_excdtl-menge and j_1iexcdtl-menge?

What dictionary data element do they refer to?

Do you have the Fixed Point Arithmetic flag set in the attributes of your program?

balaji_viswanath
Participant
0 Kudos

Thanks Charles.

Fixed Point Arithmetic flag was not set...I don't know how it got removed... it's by default set know?... after setting it, program is working fine.

Regards,

Balaji Viswanath.

Answers (1)

Answers (1)

christian_wohlfahrt
Active Contributor
0 Kudos

Hello Balaji,

one possible reason:

fields it_excdtl-exbas and it_excdtl-menge are referred to currency and unit fields. They are filled in your 11.05-case. Behind currency decimal definition can be customized (e.g. US-dollar 2, Italian Lira 0). Behind unit decimals can be customized (e.g. kilogram 3, piece 0). So different 'real' amounts can be defined.

Theses customizing is different to the number of default decimals, which is defined behind fields exbas and menge - which is used in debugger and SE16.

Check, if your currency for exbas has 5 decimals (table TCURX) - then 11.06 is correct value.

If you can't find a reason - just move value and amount into dummy-fields before calculation. Then it should work like i_fieldx-example.

Regards,

Christian