Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

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.