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: 

Getting Unit Price from Net Price by dividing with Quantity.

0 Kudos
1,294

Good Day Guys,

I have a requirement, wherein I've got to find the Unit Price Per Item, by Dividing Net Price with the Quantity.

Currently, Quantity field (MENGE) is of type QUAN.

Let me tell you what I experience when i divide by type QUAN:

I have Net Value : 87405.32

I have Quantity Value : 2.000 (Data Type - QUAN)

When I divide ( 87405.32 / 2.000 ), I see that I am getting, a value which is 43.72.

( It should acutally be, 43702.66 ).

So, On seeing the value 47.02, I multiply by 1000 and I now get the value 43700.00

Now, I see the Decimals, the Units, and the Tenths, are all replaced by zeroes, by doing so. This still is a problem, cause I don't get the exact value of 43702.66

I guess, I need to find a function module that will change this quantity of 2 which of type QUAN to Integer, in order to get the exact value.

Would it be possible for any of you, to give me a suggestion as to what i can do, to obtain the exact value, and if there is any function module that will convert QUAN type to Integer.

5 REPLIES 5

Former Member
0 Kudos
376

**Check this code

REPORT ZTEST3.

data:

amount like bseg-dmbtr,

quantity like bseg-menge,

unit_rate like bseg-dmbtr.

amount = '87405.32'.

quantity = '2.000'.

unit_rate = amount / quantity.

write unit_rate.

Former Member
0 Kudos
376

I don't see the problem - I get the correct result of 43702.66. What type's are using for your variables?

DATA: lv_qty TYPE BSTMG VALUE '2.000',

lv_price TYPE BPREI VALUE '87405.32',

lv_result TYPE BPREI.

lv_result = lv_price / lv_qty.

0 Kudos
376

Hi,

Actually, I did not explain well i guess.

What is happening is that I am getting these values, from an excise table,

J_1IEXCDTL.

For Net Price, from table J_1IEXCDTL.

This has, Field : EXBAS,

Data Element : J_1IEXCBAS

Domain : WERT7

Domain WERT7 is of type, CURR.

For Quantity this, from table J_1IEXCDTL.

This has, Field: : MENGE

Data Element : J_1IMENGE

Domain : MENG13

Domain MENG13 is of type, QUAN

So, if you do lv_result = lv_price / lv_qty, then you won't get 43702.66. Instead, you'll get 43.72.

0 Kudos
376
        • I still don't understand why r u not getting correct answer

data:

amount like J_1IEXCDTL-EXBAS,

quantity like J_1IEXCDTL-menge,

unit_rate like J_1IEXCDTL-EXBAS.

amount = '87405.32'.

quantity = '2.000'.

unit_rate = amount / quantity.

write unit_rate. "43,702.66

Former Member
0 Kudos
376

Then move you data from the table J_1IEXCDTL to local variables and then do your calculation?