cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_PO_CHANGE Extension for Custom Fields in S/4HANA

frasseli
Explorer
8,851

Hello Community!

My team is confronting a strange behaviour when implementing a custom field in PO Item table EKPO and trying to change it’s value through BAPI_PO_CHANGE on a S/4HANA on premise environment. Mind that the same implementation is working properly on the old ECC system.

Here are the details:

This is the custom field ZZPODATE in EKPO

Here are the extension includes:

CI_EKPODB

CI_EKPODBX

Here is a code snippet that should be working in S/4HANA, but only works in ECC:

  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.

  DATA:  lt_return TYPE TABLE OF bapiret2.

  CLEAR: lt_item, lt_itemx, lt_extensionin.

  str_item-po_item = str_itemx-po_item = '00010'.
  APPEND str_item TO lt_item.
  APPEND str_itemx TO lt_itemx.

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

  str_extensionin-structure      = 'BAPI_TE_MEPOITEM'.
  str_extensionin-valuepart1     = str_bapi_te_mepoitem.
  APPEND str_extensionin TO lt_extensionin.
  
  str_extensionin-structure      = 'BAPI_TE_MEPOITEMX'.
  str_extensionin-valuepart1     = str_bapi_te_mepoitemx.
  APPEND str_extensionin TO lt_extensionin.

  CLEAR lt_return.
  
  CALL FUNCTION 'BAPI_PO_CHANGE'
    EXPORTING
      purchaseorder = '4500000394' "ebeln
    TABLES
      return        = lt_return
      poitem        = lt_item
      poitemx       = lt_itemx
      extensionin   = lt_extensionin.

  COMMIT WORK AND WAIT.

It should be noted that I have debugged the BAPI_PO_CHANGE and the PERFORM move_extensionin is executed as expected and the value for the field ZZPODATE is correctly mapped to the cht_poitem and cht_poitemx tables.

I have also checked the note "1895028 - Custom fields are not been transferred when using BAPI" and everything looks to be in order.

Any help would be awesome!

Thanks.

Accepted Solutions (0)

Answers (2)

Answers (2)

teampro2016_
Explorer
0 Kudos

Hi,

You can find the sample code line below;

NTeunckens
Active Contributor
0 Kudos

Can you please investigate that your ECC System is Unicode or not? The S/4HANA System will be a Unicode System, my guess is your ECC System is not. Passing data in the Extension-Structures is less restrictive in ECC ...

Please see SAP-Note 509898 - BAPI enhancement concept and Unicode - SAP ONE Support Launchpad on this. The Note offers advice on either changing the Datatype or doing a kind of Mapping of your Enhancement Structure to something like a "Character-based Copy of your Custom Structure". Using that workaround should offer better results ...

Kind regards

Nic T.