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: 

Using BAPI_PO_CHANGE to update z-field.

Former Member
0 Kudos
4,344

I want to update a Z field (customer include) in table EKKO. I want to use BAPI_PO_CHANGE with parameter extensionin.

Can anyone show an working example code.

Thanx in advance.

1 REPLY 1

Jelena_Perfiljeva
Active Contributor
0 Kudos
735

I just did a test today, seems to be working. We have a custom field EKKO-ZZDELIVERYDATE. To work with BAPI, this field must be included in two structures:

1) BAPI_TE_MEPOHEADER, there is an include CI_EKKODB. Add the Z field there with the same type as on EKKO. (I actually didn't have to do this - either somebody has already done this or it happened automatically when the fiel was added, not sure).

2) BAPI_TE_MEPOHEADERX, include CI_EKKODBX. Add the field with the same name but type BAPIUPDATE (!).

PARAMETERS:  p_ebeln TYPE ebeln,
             p_date LIKE sy-datum.

DATA: s_header TYPE bapimepoheader,
      s_headerx TYPE bapimepoheaderx,
      i_return TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
      i_extension TYPE bapiparex OCCURS 0 WITH HEADER LINE,
      s_bapi_te_mepoheader TYPE bapi_te_mepoheader,
      s_bapi_te_mepoheaderx TYPE bapi_te_mepoheaderx,
      wa_date TYPE ekko-zzdeliverydate,
      wa_message TYPE c LENGTH 100.

s_bapi_te_mepoheaderx-po_number = p_ebeln.
s_bapi_te_mepoheaderx-zzdeliverydate = 'X'.
s_bapi_te_mepoheader-po_number = p_ebeln.
s_bapi_te_mepoheader-zzdeliverydate = p_date.
i_extension-structure = 'BAPI_TE_MEPOHEADER'.
i_extension-valuepart1 = s_bapi_te_mepoheader.
APPEND i_extension.
i_extension-structure = 'BAPI_TE_MEPOHEADERX'.
i_extension-valuepart1 = s_bapi_te_mepoheaderx.
APPEND i_extension.

s_header-po_number = p_ebeln.

CALL FUNCTION 'BAPI_PO_CHANGE'
  EXPORTING
    purchaseorder = p_ebeln
  TABLES
    return        = i_return
    extensionin   = i_extension.

COMMIT WORK.
LOOP AT i_return.
  MESSAGE ID   i_return-id
       TYPE    i_return-type
       NUMBER  i_return-number WITH
               i_return-message_v1
               i_return-message_v2
               i_return-message_v3
               i_return-message_v4.
ENDLOOP.