Skip to Content
0
Jun 04, 2020 at 04:01 PM

BAPI_PO_CHANGE

202 Views

data(lt_temp) = lt_data. 


LOOP AT lt_temp ASSIGNING FIELD-SYMBOL(<fsl_temp>).
        ls_poheader-po_number = <fsl_temp>-ebeln.
        ls_poheaderx-po_number = 'X'.
        READ TABLE lt_data INTO DATA(ls_data) WITH KEY ebeln = <fsl_temp>-ebeln BINARY SEARCH.
        IF sy-subrc IS INITIAL.
          ls_poitem-po_item = ls_data-ebelp.
          ls_poitem-delete_ind = 'L'.
          ls_poitemx-po_item = 'X'.
          ls_poitemx-delete_ind = 'X'.
          APPEND ls_poitem TO lt_poitem.
          APPEND ls_poitemx TO lt_poitemx.
          CLEAR: <fsl_temp>.
        ENDIF.
    CALL FUNCTION 'BAPI_PO_CHANGE'
      EXPORTING
        purchaseorder = ls_data-ebeln
*       poheader      = ls_poheader
*       poheaderx     = ls_poheaderx
      TABLES
        return        = lt_return
        poitem        = lt_poitem
        poitemx       = lt_poitemx.
endloop.


    READ TABLE lt_return INTO ls_return WITH KEY  type = 'E'.
    IF sy-subrc NE 0.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ENDIF.<br>

Hello.

I have fetched ebeln,ebelp and other fields using select query into table lt_data using select options given in selection screen.

Now I have multiple purchase orders & multiple line items.Need to call BAPI

"BAPI_PO_CHANGE".

How to fill the purchase order and its corresponding line items and pass it to BAPI.

This is the code i have written.