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 add line

Former Member
0 Kudos

Hello

I have read all possible topics regarding my problem but still i did manage to add a line in my PO.

I want to copy the existing purchase order lines and add new lines with another purchase requisition.

I appended the po lines to the table POITEM and added de po item number in the POITEMX table but still i just get the error message : item XXX does not exist

It is refering to the item number that i gave for the items to be added.Which is the indicator telling the bapi to add the lines?

thank you

5 REPLIES 5

krishnendu_laha
Active Contributor
0 Kudos

Hello,

Could you please try to padding zero's before the line item number?

Exaxmple:

Item number if you are passing 10, it should be 00010 like.

Thanks.

Former Member
0 Kudos

Hi

I believe this is because as you said you have added new line from another PR.

If you want to change the value then the flow should be like.

first get the details.

then make the changes and then

call BAPI_TRANSACTION_COMMIT.

I hope you are follwoing the same sequence and also you have mainteained the values for BAPIMEPOITEMX table as well.

you cannot add another line item in existing PO items therefore you are getting the error message as you have mentioned. because that line item does not exists in the PO and you are trying to add it via BAPI_CHANGE which is not possible in my knowledge.

you can make changes only in existing values.

hopw I make this clear to you.

Thanks

Lalit Gupta

0 Kudos

A stupid question now.Is it possible to add PO lines with this bapi or do i have to use the BAPI_PO_CREATE function to add a line in the PO?

0 Kudos

Hi Seba

I believe this is not a kind of business senario you will ever find.

and by the ways it is not possible to add line item in an existing PO using BAPI_PO_CREATE because this wil create another PO instead of adding line item values in the existing PO.

you can add line item using ME22N, if you have authorisation.

I hope this wil clear your doubt/problem.

Thanks

Lalit Gupta

0 Kudos

Well,i have managed to create PO lines with this BAPI_PO_CHANGE fm,bellow is the code:

we have to set the X mark for the mandatory fields that need to be inserted,just like the ones that you have to provide in ME22N when adding a line.This X marks are enterred only for the lines to be added,so,for the existing ones i have not added any X in the X tables.

In the tables LT_POITEM, LT_POSCHEDULE and LT_POACCOUNT i have all the lines that are already existing in the PO and additional i have added new entries with all the fields that are bellow filled with custom po item number.

LT_POITEMX-PO_ITEM = LV_ITM.

LT_POITEMX-PO_ITEMX = 'X'.

LT_POITEMX-ACCTASSCAT = 'X'.

LT_POITEMX-SHORT_TEXT = 'X'.

LT_POITEMX-QUANTITY = 'X'.

LT_POITEMX-PO_UNIT_ISO = 'X'.

LT_POITEMX-PLANT = 'X'.

LT_POITEMX-NET_PRICE = 'X'.

LT_POITEMX-PRICE_UNIT = 'X'.

LT_POITEMX-MATL_GROUP = 'X'.

LT_POITEMX-ORDERPR_UN = 'X'.

LT_POITEMX-PREQ_NO = 'X'.

LT_POITEMX-PREQ_ITEM = 'X'.

LT_POITEMX-PREQ_NAME = 'X'.

APPEND LT_POITEMX.

LS_POACCOUNTX-PO_ITEM = LV_ITM.

LS_POACCOUNTX-PO_ITEMX = 'X'.

LS_POACCOUNTX-GL_ACCOUNT = 'X'.

LS_POACCOUNTX-NETWORK = 'X'.

LS_POACCOUNTX-ACTIVITY = 'X'.

APPEND LS_POACCOUNTX TO LT_POACCOUNTX.

LS_POSCHEDULEX-PO_ITEM = LV_ITM.

LS_POSCHEDULEX-DELIVERY_DATE = 'X'.

APPEND LS_POSCHEDULEX TO LT_POSCHEDULEX.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

PURCHASEORDER = LS_RSDB-EBELN

  • POHEADER =

  • POHEADERX =

  • POADDRVENDOR =

  • TESTRUN =

  • MEMORY_UNCOMPLETE =

  • MEMORY_COMPLETE =

  • POEXPIMPHEADER =

  • POEXPIMPHEADERX =

  • VERSIONS =

  • NO_MESSAGING =

  • NO_MESSAGE_REQ =

  • NO_AUTHORITY =

  • NO_PRICE_FROM_PO =

  • IMPORTING

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

TABLES

RETURN = LT_RETURN

POITEM = LT_POITEM

POITEMX = LT_POITEMX

  • POADDRDELIVERY =

POSCHEDULE = LT_POSCHEDULE

POSCHEDULEX = LT_POSCHEDULEX

POACCOUNT = LT_POACCOUNT

  • POACCOUNTPROFITSEGMENT =

POACCOUNTX = LT_POACCOUNTX