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

Divideing price to quantity problem.

Former Member
0 Likes
1,432

Hello Gurus, i need to calculate the material price, i have tried to divide the total price (MSEG-EXBWR type) with the quantity (MSEG-ERFMG type) but it`s not working.

Please help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,267

Sorry for not being clear enought. I have tried to divide the total price (MSEG-EXBWR type) with the quantity (MSEG-ERFMG type) but it`s not working; this is the code:


MODULE GET_PREIS INPUT.
data: preist like mseg-EXBWR,
        quant like mseg-ERFMG,
        preis type mseg-EXBWR,
        preis_text type char20.

preist = mseg-EXBWR.
quant = mseg-ERFMG.

preis = preist / quant. "0.01 = 12.36 / 2.000 (the result is not good)
preis_text = preis.
CONDENSE preis_text.
set PARAMETER ID 'ZPR' field preis_text.

ENDMODULE. 

I have also tried to convert the values to p type (with o without the number of decimals equal: preis type p decimals 3 and quant type p decimals 3), but still no luck.

Please help.

10 REPLIES 10
Read only

matt
Active Contributor
0 Likes
1,267

How is it "not working"?

Read only

Former Member
0 Likes
1,267

Hi,

Please be clear in what you want to tell us.

Try to use a packed decimal variable and see. this might work for you.

Please close , if solved

Read only

Former Member
0 Likes
1,268

Sorry for not being clear enought. I have tried to divide the total price (MSEG-EXBWR type) with the quantity (MSEG-ERFMG type) but it`s not working; this is the code:


MODULE GET_PREIS INPUT.
data: preist like mseg-EXBWR,
        quant like mseg-ERFMG,
        preis type mseg-EXBWR,
        preis_text type char20.

preist = mseg-EXBWR.
quant = mseg-ERFMG.

preis = preist / quant. "0.01 = 12.36 / 2.000 (the result is not good)
preis_text = preis.
CONDENSE preis_text.
set PARAMETER ID 'ZPR' field preis_text.

ENDMODULE. 

I have also tried to convert the values to p type (with o without the number of decimals equal: preis type p decimals 3 and quant type p decimals 3), but still no luck.

Please help.

Read only

0 Likes
1,267

Anyone ?

Read only

matt
Active Contributor
0 Likes
1,267

Have you got fixed point arithmetic set on the attributes of the program?

matt

Read only

0 Likes
1,267

It is a SAP transaction that i have to modify, transaction "MB1C", program SAPMM07M. And no, fixed point arithmetic is not checked.

Edited by: Ioan Constantin on Aug 11, 2008 4:11 PM

Read only

matt
Active Contributor
0 Likes
1,267

Posting the same question multiple times is contrary to forum rules. It fragments answers, and make it less likely for you to get consistent answers.

It's a standard SAP program, so you shouldn't change that flag. Instead, put the division coding into a function module/subroutine pool/class or the like, in your customer name space, and make sure that has the flag set.

matt

Read only

0 Likes
1,267

Thank you for the answer.

Regarding the multiple posted question, i didn`t know how to move it.

I apologize.

Read only

0 Likes
1,267

It's not moved. It's deleted.

Please read [the other rules|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement] as well, incase you are not aware of them.

Cheers,

Julius

Read only

matt
Active Contributor
0 Likes
1,267

>

> Thank you for the answer.

> Regarding the multiple posted question, i didn`t know how to move it.

> I apologize.

No worries, we're all learning.