Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

populate custom fields in EKPO using Bapi_po_change

Hi all,

I have a requirement to update the custom fields in EKPO using BAPI_PO_CHANGE.

How to use the Extensionin Parameter and what are the structures i need to use.

Provide me sample code to populate EKPO fields.

Thanks,

Suresh

Former Member
Former Member replied

Sample code to populate EKPO fields:

method bapi_update_po_item. 
  data: lt_item               type table of bapimepoitem, 
        str_item              type bapimepoitem, 
        lt_itemx              type table of bapimepoitemx, 
        str_itemx             type bapimepoitemx, 
        lt_extensionin        type table of bapiparex, 
        str_extensionin       type bapiparex, 
        str_bapi_te_mepoitem  type bapi_te_mepoitem, 
        str_bapi_te_mepoitemx type bapi_te_mepoitemx. 

  clear: lt_item[], lt_itemx[], lt_extensionin[]. 
  str_item-po_item = str_itemx-po_item = ebelp. 
  append str_item to lt_item. 
  append str_itemx to lt_itemx. 

*------------------------* 
*-New Z-fields in EKPO  -* 
*------------------------* 
  str_bapi_te_mepoitemx-po_item    = ebelp. 
  str_bapi_te_mepoitemx-zi_expdate = 'X'. 
  str_bapi_te_mepoitem-po_item     = ebelp. 
  str_bapi_te_mepoitem-zi_expdate  = sy-datum. 

  str_extensionin-structure        = 'BAPI_TE_MEPOITEM'. 
  str_extensionin-valuepart1(114)  = str_bapi_te_mepoitem(114). 
  append str_extensionin to lt_extensionin. 
  str_extensionin-structure        = 'BAPI_TE_MEPOITEMX'. 
  str_extensionin-valuepart1(12)   = str_bapi_te_mepoitemx(12). 
  append str_extensionin to lt_extensionin. 

  clear return_t[]. 
  call function 'BAPI_PO_CHANGE' 
    exporting 
      purchaseorder = ebeln 
    tables 
      return        = return_t 
*     poitem        = lt_item 
*     poitemx       = lt_itemx 
      extensionin   = lt_extensionin. 
  commit work and wait. 

endmethod. 

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question