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: 

BAPI_PO_CHANGE for changing quantity of line item

Former Member
0 Kudos

Hai frnds,

Im using BAPI_PO_CHANGE for changing the quantity field of an existing PO line item.

Based on the over tolerance limit, the percentage(tolerance percentage) on the existing quantity will be added to the existing line item qunatity.

Eg: existing quantity = 100,

tolerance percentage = 5%[5 quantity = 5%(100)],

changed quantity = 105.

But the quantity is getting added up as below,

existing quantity = 100,

tolerance percentage = 5%[5 quantity = 5%(100)],

changed quantity = 205.

This happens only for the first time, next time u add up to the quantity is calculated as per requirement.

Can anyone help out to solve this issue, as my calculation is going correctly until it reaches BAPI.Can u suggest the problem behind this?????

Regrads,

Suganya Jayabalan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Jaya ,

this is problem with ur Internal table Calc.

u have to put logic like this.

loop at item.

w_tpet = ( item-quantity * 5 ) / 100."value will be 5

item-quantity = item-quantity + w_tpet.

modify item.

clear w_tpet.

endloop.

orelse.

loop at item.

item-quantity = item-quantity + ( item-quantity * 5 ) / 100."value will be 5

modify item.

endloop.

<b>Hi ,

BAPI will not calc like this ,how u are calling second time ? in the same program or again u are executing the report.If u are getting right figure in second time only then Def.problem with the program .Before calling the BAPI check ur ITEM table and make sure that after committing the work u have to REFRESH all Internal table.

Regards

Prabhu</b>

4 REPLIES 4

Former Member
0 Kudos

Hi Jaya ,

this is problem with ur Internal table Calc.

u have to put logic like this.

loop at item.

w_tpet = ( item-quantity * 5 ) / 100."value will be 5

item-quantity = item-quantity + w_tpet.

modify item.

clear w_tpet.

endloop.

orelse.

loop at item.

item-quantity = item-quantity + ( item-quantity * 5 ) / 100."value will be 5

modify item.

endloop.

<b>Hi ,

BAPI will not calc like this ,how u are calling second time ? in the same program or again u are executing the report.If u are getting right figure in second time only then Def.problem with the program .Before calling the BAPI check ur ITEM table and make sure that after committing the work u have to REFRESH all Internal table.

Regards

Prabhu</b>

0 Kudos

Hai Prabhu,

Thzs for ur reply. I have checked with my calculation for the internal table, it is going fine as per requirement.The values are passed correctly into the BAPI_PO_CHANGE, but it is getting changed inside the bapi,i.e., getting added for the first time alone(The next time wen i do the same, it going fine). please guide me in this...

Regrads,

Suganya Jayabalan

0 Kudos

Hi,

Im executing the report for the second time. I have checked with my item table and also i have refershed all internal table.This problem exist eventhough everything is maintained. Any other problem may be there? I have checked with my internal table, quantity is calculated correctly.

Regrads,

Suganya Jayabalan

0 Kudos

Hi,

This is the data im passing to BAPI_PO_CHANGE.

wrong calculation: 1st execution

Quantity = 80 to be changed to 81.

t_zmmpo_amend_tab-ebeln = 0370000017.

t_bapimepoitem_tab1 :

PO_ITEM = 00021

SHORT_TEXT = MATERIAL FOR TEST

MATERIAL = MATERIAL1

PLANT = 0610

INFO_REC = 5300000233

QUANTITY = 81.000

PO_UNIT_ISO = PCE

ORDERPR_UN = PC

ORDERPR_UN_ISO = PCE

CONV_NUM1 = 1

CONV_DEN1 = 1

NET_PRICE = 123.000000000

PRICE_UNIT = 1

TAX_CODE = 0I

INFO_UPD = C

PRNT_PRICE = X

GR_IND = X

IR_IND = X

GR_BASEDIV = X

CMMT_ITEM = 171003

PRICE_DATE = 20061106

PREQ_NO = 0010003021

PREQ_ITEM = 00010

CMMT_ITEM_LONG = 171003

t_bapimepoitemx_tab :

PO_ITEM = 00021

PO_ITEMx = X

QUANTITY = X

t_bapiposchedule :

PO_ITEM = 00021

SCHED_LINE = 0002

QUANTITY = 1.000

PREQ_NO = 0010003021

PREQ_ITEM = 00010

t_bapiposchedulex :

PO_ITEM = 00021

SCHED_LINE = 0002

PO_ITEMX = X

SCHED_LINEX = X

QUANTITY = X

PREQ_NO = X

PREQ_ITEM = X

t_bapimepocond_tab :

ITM_NUMBER = 000021

COND_TYPE = ZVCD

COND_VALUE = 1185.000000000

CURRENCY = INR

ITM_NUMBER = 000021

COND_TYPE = ZVNV

COND_VALUE = 1707.000000000

CURRENCY = INR

ITM_NUMBER = 000021

COND_TYPE = ZCCD

COND_VALUE = 58.000000000

CURRENCY = INR

ITM_NUMBER = 000021

COND_TYPE = ZVAE

COND_VALUE = 499.000000000

CURRENCY = INR

ITM_NUMBER = 000021

COND_TYPE = ZCCN

COND_VALUE = 50.000000000

CURRENCY = DEM

ITM_NUMBER = 000021

COND_TYPE = ZPCL

COND_VALUE = 0.500000000

CURRENCY = %

Result:

QUANTITY = 80 => QUANTITY = 161 (80 + 81)

correct calculation : 2nd execution

Quantity = 161 to be changed to 162.

t_zmmpo_amend_tab-ebeln = 0370000017.

t_bapimepoitem_tab1 :

PO_ITEM = 00021

SHORT_TEXT = MATERIAL FOR TEST

MATERIAL = MATERIAL1

PLANT = 0610

INFO_REC = 5300000233

QUANTITY = 162.000

PO_UNIT_ISO = PCE

ORDERPR_UN = PC

ORDERPR_UN_ISO = PCE

CONV_NUM1 = 1

CONV_DEN1 = 1

NET_PRICE = 123.310000000

PRICE_UNIT = 1

TAX_CODE = 0I

INFO_UPD = C

PRNT_PRICE = X

GR_IND = X

IR_IND = X

GR_BASEDIV = X

CMMT_ITEM = 171003

PRICE_DATE = 20061106

PREQ_NO = 0010003021

PREQ_ITEM = 00010

CMMT_ITEM_LONG = 171003

t_bapimepoitemx_tab :

PO_ITEM = 00021

PO_ITEMx = X

QUANTITY = X

t_bapiposchedule :

PO_ITEM = 00021

SCHED_LINE = 0003

QUANTITY = 1.000

PREQ_NO = 0010003021

PREQ_ITEM = 00010

t_bapiposchedulex :

PO_ITEM = 00021

SCHED_LINE = 0003

PO_ITEMX = X

SCHED_LINEX = X

QUANTITY = X

PREQ_NO = X

PREQ_ITEM = X

t_bapimepocond_tab :

ITM_NUMBER = 000021

COND_TYPE = ZVCD

COND_VALUE = 1185.000000000

CURRENCY = INR

ITM_NUMBER = 000021

COND_TYPE = ZVNV

COND_VALUE = 1707.000000000

CURRENCY = INR

ITM_NUMBER = 000021

COND_TYPE = ZCCD

COND_VALUE = 58.000000000

CURRENCY = INR

ITM_NUMBER = 000021

COND_TYPE = ZVAE

COND_VALUE = 499.000000000

CURRENCY = INR

ITM_NUMBER = 000021

COND_TYPE = ZCCN

COND_VALUE = 50.000000000

CURRENCY = DEM

ITM_NUMBER = 000021

COND_TYPE = ZPCL

COND_VALUE = 0.500000000

CURRENCY = %

Result:

QUANTITY = 161 => QUANTITY = 162 (161 + 1)