Skip navigation

Tag Archives: Delete PO Item using BAPI

BAPI_PO_CHANGE bisa digunakan untuk menghapus item PO. berikut ini adalah contoh parameter yang di-input dalam pemograman abap untuk menghapus item pada PO.

  DATA: lt_poitem   LIKE bapimepoitem OCCURS 0 WITH HEADER LINE,
      lt_poitemx  LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE,
      lt_return   LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
      ld_ponum    LIKE bapimepoheader-po_number,
      lt_ekko     LIKE ekko OCCURS 0 WITH HEADER LINE,
      lt_ekpo     LIKE ekpo OCCURS 0 WITH HEADER LINE.

  PARAMETERS p_ebeln LIKE ekko-ebeln.

  SELECT * FROM ekko INTO TABLE lt_ekko WHERE ebeln = p_ebeln.
  SELECT * FROM ekpo INTO TABLE lt_ekpo WHERE ebeln = p_ebeln.

  READ TABLE lt_ekko.
  ld_ponum = lt_ekko-ebeln.

  LOOP AT lt_ekpo WHERE ebeln = lt_ekko-ebeln.
*input parameter table
    CLEAR: lt_poitem, lt_poitemx.
    lt_poitem-po_item     = lt_ekpo-ebelp.
    lt_poitem-delete_ind  = 'X'.

    lt_poitemx-po_item     = lt_ekpo-ebelp.
    lt_poitemx-po_itemx    = 'X'.
    lt_poitemx-delete_ind  = 'X'.

    APPEND: lt_poitem, lt_poitemx.
  ENDLOOP.

  CALL FUNCTION 'BAPI_PO_CHANGE'
    EXPORTING
      purchaseorder = ld_ponum
    TABLES
      return        = lt_return
      poitem        = lt_poitem
      poitemx       = lt_poitemx.

  READ TABLE lt_return WITH KEY type = 'E'.
  IF sy-subrc EQ 0.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
  ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.
  ENDIF.
Advertisements
%d bloggers like this: