Skip to Content
Former Member
May 08, 2018 at 06:25 PM

BAPI_PO_CHANGE new po item


Hi Everyone,

I'm looking to use the BAPI_PO_CHANGE new po item based on a customer PO that is automatically generated by ERB Catalog.
I've looked at plenty of other wiki results here, and haven't found anything that particularly helps my case.

Here is my code, can anyone lend a hand at what I'm doing wrong to add the line.

        ls_mepoheader     type          bapimepoheader,
        ls_mepoheaderx    type          bapimepoheaderx,
        ls_mepoitem       type          bapimepoitem,
        ls_mepoitemx      type          bapimepoitemx,
        ls_poaccount      type          bapimepoaccount,
        ls_poaccountx     type          bapimepoaccountx,
        ls_meposchedule   type          bapimeposchedule,
        ls_meposchedulx   type          bapimeposchedulx,
        ls_mepocond       type          bapimepocond,
        ls_mepocondx      type          bapimepocondx,
        lv_new_ebelp      type          ebelp,
        lt_mepoitem       type table of bapimepoitem,
        lt_mepoitemx      type table of bapimepoitemx,
        lt_poaccount      type table of bapimepoaccount,
        lt_poaccountx     type table of bapimepoaccountx,
        lt_meposchedule   type table of bapimeposchedule,
        lt_meposchedulx   type table of bapimeposchedulx,
        lt_mepocond       type table of bapimepocond,
        lt_mepocondx      type table of bapimepocondx,
        ls_return         type bapiret2,
        lv_delivery       type          datum.

  perform next_ebelp. "Increments the ebelp line. 

"PO HEADER Table Fill
  ls_mepoheader-po_number = ls_equipment_r-po_quarterly.
  "Nothing Changes in the Header. (No 'X' in X Struct)
"PO ITEM Table Fill ls_mepoitem-po_item = ls_equipment_r-quarterly_ebelp. ls_mepoitemx-po_item = ls_equipment_r-quarterly_ebelp. ls_mepoitemx-po_itemx = 'X'. ls_mepoitem-short_text = ls_equipment_r-short_text. ls_mepoitemx-short_text = 'X'. ls_mepoitem-net_price = ls_equipment_r-price. ls_mepoitemx-net_price = 'X'. ls_mepoitem-acknowl_no = ls_equipment_r-equi_number. ls_mepoitemx-acknowl_no = 'X'. ls_mepoitem-preq_no = ls_equipment_r-pr. ls_mepoitemx-preq_no = 'X'. ls_mepoitem-preq_item = ls_equipment_r-po_line. ls_mepoitemx-preq_item = 'X'. ls_mepoitem-quantity = ls_zitpm07-billingtime. ls_mepoitemx-quantity = 'X'. "PO SCHEDULE Table Fill ls_meposchedule-po_item = ls_equipment_r-quarterly_ebelp. ls_meposchedule-delivery_date = lv_delivery. ls_meposchedulx-delivery_date = 'X'. ls_meposchedule-sched_line = ls_equipment_r-quarterly_ebelp. ls_meposchedule-quantity = ls_zitpm07-billingtime. ls_meposchedulx-quantity = 'X'. ls_meposchedule-sched_line = ls_equipment_r-quarterly_ebelp. ls_meposchedulx-sched_line = 'X'. "PO ACCOUNT Table Fill ls_poaccount-po_item = ls_equipment_r-quarterly_ebelp. ls_poaccount-costcenter = ls_equipment_r-cost_center. ls_poaccountx-costcenter = 'X'. "PO COND Table Fill ls_mepocond-itm_number = ls_equipment_r-quarterly_ebelp. ls_mepocondx-itm_number = 'X'. append ls_mepoitem to lt_mepoitem. append ls_mepoitemx to lt_mepoitemx. append ls_meposchedule to lt_meposchedule. append ls_meposchedulx to lt_meposchedulx. append ls_poaccount to lt_poaccount. append ls_poaccountx to lt_poaccountx. append ls_mepocond to lt_mepocond. append ls_mepocondx to lt_mepocondx. call function 'BAPI_PO_CHANGE' exporting purchaseorder = ls_equipment_r-po_quarterly tables return = lt_return poItem = lt_mepoitem poItemX = lt_mepoitemx poSchedule = lt_meposchedule poSchedulex = lt_meposchedulx poaccount = lt_poaccount poAccountx = lt_poaccountx poCond = lt_mepocond poCondx = lt_mepocondx.

I'm also including the two errors that are most likely the culprits of the problem:
E - BAPI - 003 Instance 4500900444 of Object type Purchase Order could not be changed -poitem

E -MEPO - 001 - Purchase Order Item 00390 still contains faulty schedule lines - poitem

E- 06 - 054 - Doc. type/item cat. ZEB/ (requisition) <-> NB/ (purch. order) - poschedule

Thank you so much for giving me a hand!