1. 程式人生 > >刪除外向交貨單 BAPI_OUTB_DE…

刪除外向交貨單 BAPI_OUTB_DE…

Change outbound delivery (VL02)
 To delete the outbound delivery pass VBRP-VGBEL (Document number of the reference document) to the function module & set dlv_del flag 'X'. To check the functionality of the function module go to ME23N transaction, pass the purchase order number. After successfully execution of function module it will delete the delivery from ME23N transaction.

 *---declaration of BAPI
   DATA: wa_hdata    LIKE bapiobdlvhdrchg,
         wa_hcont    LIKE bapiobdlvhdrctrlchg,
         d_delivy    LIKE bapiobdlvhdrchg-deliv_numb,
         it_bapiret2 LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
 Loop at it_vbrp.
CLEAR: wa_hdata, wa_hcont, d_delivy, it_bapiret2.
     wa_hdata-deliv_numb = it_vbrp-vgbel.

     wa_hcont-deliv_numb = it_vbrp-vgbel.
     wa_hcont-dlv_del    = c_x.
     d_delivy            = it_vbrp-vgbel.
*---Deleting delivery doc (VL02)
     CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
       EXPORTING
         header_data    = wa_hdata
         header_control = wa_hcont
         delivery       = d_delivy

       TABLES
         return         = it_bapiret2.
 *---commit
       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
         EXPORTING
           wait = 'X'.
Endloop.