cancel
Showing results for 
Search instead for 
Did you mean: 

problem with quantity and currency fields

Former Member
0 Kudos
844

Hello Friends,

I am using table J_1IEXCDTL for my report and in my report I am calculating Net price for a unit quantity by doing

net_price = J_1IEXCDTL-EXBAS / J_1IEXCDTL-MENGE.

for eg. my value for <b>J_1IEXCDTL-EXBAS is 7129.80 and for

J_1IEXCDTL-MENGE is 5.000</b>

then i shud get a value for my variable net_price = <b>1425.96</b> which is i m not getting instead of that value i m getting <b>1.43</b> only so how do i do it as it is showing me wrong values.

regds,

pritesh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

good

check the calculation first using the debugging that what value J_1IEXCDTL-EXBAS and J_1IEXCDTL-MENGE before storing the final value in net_price.

There must be some problem in the calculation.

thanks

mrutyun^

Former Member
0 Kudos

Hi Friends thanks for replying to my question but my problem has not been solved yet. I have declared

data: net_price type TYPE p decimals 2. and did the calculation

net_price = J_1IEXCDTL-EXBAS / J_1IEXCDTL-MENGE.

still net_price = 1.43

then i changed my declaration as below

data: net_price type TYPE J_1IEXCDTL-EXBAS.

Still the net_price = 1.43

pls help.

pritesh

Former Member
0 Kudos

this is due to Decimal Problem.

try to put like this and check all possible ways.

net_price = ( J_1IEXCDTL-EXBAS / J_1IEXCDTL-MENGE ) * 100.

Regards

Prabhu

Former Member
0 Kudos

No its showing wrong values Prabhu. its showing net_price = <b>143.00</b> and i want

as J_1IEXCDTL-EXBAS = 7129.80 AND J_1IEXCDTL-MENGE = 5.000

Net_price = J_1IEXCDTL-EXBAS / J_1IEXCDTL-MENGE .

net_price = <b>1425.96</b>

pls help.

Former Member
0 Kudos

<b>try this one.</b>

u cannt use TYPE p.

EPORT ZPRABHU .

data: gross like J_1IEXCDTL-EXBAS,

qty like J_1IEXCDTL-menge,

<b> net like bseg-dmbtr.</b>

gross = '7129.80'.

qty = '5.000'.

net = gross / qty.

Regards

Prabhu

Former Member
0 Kudos

Hello Prabhu ,

it gives wrong values.

Former Member
0 Kudos

pritesh tell me the data types for menge and exbas u used

Former Member
0 Kudos

Hello Suresh,

I used reference field for menge from J_1iexcdtl-menge and exbas type j_1iexcdtl-exbas

The datatype used for menge is QUAN LENGTH 13 AND DECIMAL PLACES 3 as shown in dictionary and for EXBAS it is CURR length 13 and decimal places 2.

Former Member
0 Kudos

try this one change the variables

data : num like ekpo-netpr,den like ekpo-menge.

data: res type p decimals 2.

num = '7129.80'

den = 5.

res = num / den.

write: num,den,res.

Former Member
0 Kudos

Hi suresh its giving me wrong value of 143.00 and it shud be 1425.96

Former Member
0 Kudos

hello agarwal,

try this code. you will get the desired result.

DATA : exbas type J_1IEXCBAS value '7129.80',

menge type j_1imenge value '5.000',

var type j_1iexcbas.

var = exbas / menge.

WRITE var.

thanks

raju N

Former Member
0 Kudos

hi prabhu its giving me wrong value.

Former Member
0 Kudos

hi agrwal,

try this one it works

DATA : exbas type J_1IEXCBAS value '7129.80',

menge type j_1imenge value '5.000',

var type j_1iexcbas.

var = exbas / menge.

WRITE var.

thanks,

raju N

Former Member
0 Kudos

Hello raju ,

Its not working . it is giving net_price = 1.43 which is absolutely wrong.

Former Member
0 Kudos

hello agarwal,

i am not sure what the problem is, i wrote the same sample program and getting the right answer, are the input values correct. i used the same values you told. completly delete the program lines and write it once again(some times there may be junk characters when you cut and paste)

Thanks

raju N

Former Member
0 Kudos

HI RAJU,

I DID ERASED THE CODE AND WROTE IT AGAIN.

But it still showing wrong values.

thanks

Former Member
0 Kudos

i dont know what u are doing, i am getting this .

Testing

Gross = 7.129,80 Qty = 5,000 Net = 1.425,96

my code is

<b>REPORT ZPRABHU .

data: gross like J_1IEXCDTL-EXBAS,

qty like J_1IEXCDTL-menge,

net like bseg-dmbtr.

gross = '7129.80'.

qty = '5.000'.

net = gross / qty.

write:/ 'Gross = ', gross,

'Qty = ' , qty,

'Net = ' , net.</b>

Regards

Prabhu

Former Member
0 Kudos

ok than, i any case there should be very simple problem. did you look at the code i gave you, just create a sample report and check it. if you think its giving a right result, check with you debugging in your program whether the values you are imagining are in action at the time(may be some problem with header, table) like that.

Thanks

raju N

Former Member
0 Kudos

i am not doing any thing different, the only thing you need to take care is the variable type you have declared.

Is the value net value right, i means is it the same as the one you are looking for.

Thanks

raju N

Message was edited by:

krishnam Raju N

Former Member
0 Kudos

let me check again my program in debugging .

Former Member
0 Kudos

Hi raju ,

I am afraid but my code is not giving desired o/p.

My code is

data: gross like J_1IEXCDTL-EXBAS,

qty like J_1IEXCDTL-menge,

net like bseg-dmbtr.

LOOP AT TJ_1IEXCDTL INTO J_1IEXCDTL.

  • write the item details

gross = J_1IEXCDTL-EXBAS.

qty = J_1IEXCDTL-MENGE.

net = gross / qty.

ENDLOOP.

SO TELL ME IS THERE ANY MISTAKE.

PRITESH

Former Member
0 Kudos

PA ,

in Debug more any body can easly find out that values these fields having ?

y u are wasting out time , this is first time i am opening a new thread more than twice.

have u check trhe field definations of thse table ?

<b>TJ_1IEXCDTL , J_1IEXCDTL.</b>.

first ccheck and debug at ur end.

Regards

Prabhu

Former Member
0 Kudos

ok fine, your program gets the net value for the last record in the internal table.

As you are looping through and moving the date in net value gets on changing and values for the final loop remains.

you need to keep appending the values to new internal table or to the same table

before the endloop. so you can have net value for all the entries in table

And also check with the structure of your internal tables if you are updating net value is should be of same type as of net.

thanks

raju N

Message was edited by:

krishnam Raju N

Former Member
0 Kudos

raju let me clear the things to u first.

I am printing excise invoice thro sap scripts.

here is my declaration

DATA: BEGIN OF TJ_1IEXCDTL OCCURS 30.

INCLUDE STRUCTURE J_1IEXCDTL.

DATA: END OF TJ_1IEXCDTL..

data: gross like J_1IEXCDTL-EXBAS,

qty like J_1IEXCDTL-menge,

net like bseg-dmbtr.

data fetching done in between.

.

.

.

.

.

SORT TJ_1IEXCDTL.

LOOP AT TJ_1IEXCDTL INTO J_1IEXCDTL.

gross = J_1IEXCDTL-EXBAS.

qty = J_1IEXCDTL-MENGE.

net = gross / qty.

endloop.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'TOTALS'

WINDOW = 'TOTAL'

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC NE 0.

PERFORM PROTOCOL_UPDATE.

ENDIF.

this is how my code goes. Now i debugged it and got the values as follows

gross = 7129.80

qty = 5.000

net = 1.43

Now please tell me what field defination need i check?

Pritesh

Former Member
0 Kudos

in se38->program name -


>change mode->GOTO(menu) -<attributes-->tick

<b>Fixed point arithmetic</b>.

Njoy SAP.

and close this thread.

Regards

Prabhu

Former Member
0 Kudos

ok man, where are updating the values you got from net value. you are doing an loop than endloop. you are not updating any values. check you internal table and tell me the vaue of qty and gross for the last entry,

Do remember i want the values for the last record of the internal table after they are sorted.

and also check if fixed arthimetic is checked in attributs as prem said, my will be checked always as default.

Thanks

raju N

Message was edited by:

krishnam Raju N

Message was edited by:

krishnam Raju N

Former Member
0 Kudos

hi I got the answer Man Thanks for your kind concern.

Pritesh

Former Member
0 Kudos

ok tell me where have you made the mistake,

thanks

raju N

Former Member
0 Kudos

WELL I HAVE NOT DONE ANY MISTAKE I JUST FORGOT TO DO THIS

in se38->program name -


>change mode->GOTO(menu) -<attributes-->tick

<b>Fixed point arithmetic.</b>

Former Member
0 Kudos

hi Pritesh.

just do like this ..u will get your solution.

data: EXBAS like J_1IEXCDTL-EXBAS.

data: MENGE like J_1IEXCDTL-MENGE.

<b>data: net_price like J_1IEXCDTL-EXBAS.</b>

exbas = '7129.80'.

menge = '5.000'.

net_price = exbas / menge.

reward if u get solution.

Answers (5)

Answers (5)

Former Member
0 Kudos

netprice type p decimals 3

Former Member
0 Kudos

Obviously the result you are getting is 7129.80 divided by 5000 which is 1.42596 rounded off to 1.43.

To solve this :

Declare a variable of the same type as J_1IEXCDTL-EXBAS .

Move MENGE to this variable.

Now do the division with variables of the same type.

Hope this helps you.

Former Member
0 Kudos

Hi

declare ur variable as below..

<b>data:

net_price type p decimals 2.</b>

net_price = J_1IEXCDTL-EXBAS / J_1IEXCDTL-MENGE.

write: net_price.

Former Member
0 Kudos

What type have to taken net price as.... please check the variable ... chnage it to p(pack) and you will get the right value....

Hope that helps..

Regards,

Jayant

Former Member
0 Kudos

hello agarwal,

check with the variable type you declared, make sure that it would of type menge.

Thanks

raju N