https://answers.sap.com/questions/4074302/bapioutbdeliverychange-delete-delivery-line-item.html
IF delivery_item IS NOT INITIAL. "Delete particular Delivery item
SELECT SINGLE vbeln posnr charg matnr lfimg umvkz umvkn
INTO wa_lips
FROM lips
WHERE vbeln = delivery AND posnr = delivery_item.
item_data-deliv_numb = wa_lips-vbeln.
item_data-deliv_item = wa_lips-posnr.
item_data-material = wa_lips-matnr.
item_data-dlv_qty = wa_lips-lfimg.
item_data-dlv_qty_imunit = wa_lips-lfimg.
item_data-fact_unit_nom = wa_lips-umvkz.
item_data-fact_unit_denom = wa_lips-umvkn.
item_data-batch = wa_lips-charg.
APPEND item_data.
item_control-deliv_numb = wa_lips-vbeln.
item_control-deliv_item = wa_lips-posnr.
item_control-del_item = ‘X’.
APPEND item_control.
ELSE. "Delete whole Delivery
header_ctrl-dlv_del = ‘X’.
ENDIF.
ELSE.
header_ctrl-dlv_del = ‘X’.
ENDIF.
header_data-deliv_numb = delivery.
header_ctrl-deliv_numb = delivery.
CALL FUNCTION ‘BAPI_OUTB_DELIVERY_CHANGE’
EXPORTING
header_data = header_data
header_control = header_ctrl
delivery = delivery
TABLES
item_data = item_data
item_control = item_control
return = return5