How to update Delivery document header with BAPI_OUTB_DELIVERY_CHANGE when fields are not available in BAPI’s Parameter
About the Author
Vijay Agarwal is SAP Certified with vast Experience in ABAP & HCM area .He is continuously improving his skill in abap and HCM arena.
To update Delivery document header with BAPI_OUTB_DELIVERY_CHANGE
Through enhancement for those fields which are not available to pass into BAPI parameter
About the Domain
SAP ABAP/SD module can use this document. This will help them to update Delivery
Header information through BAPI’s Enhancement.
This document will cover basic steps to enhance BAPI_OUTB_DELIVERY_CHANGE to update Delivery document header table LIKP.
As there are some fields e.g. billing block LIKP-FAKSK is not available in BAPI ‘s Parameter to pass and system need to update Delivery document with these fields.
In that case with Enhancement, BAPI can be used to update delivery document although fields were not available in BAPI’s parameter for passing.
For example – There is need to update Delivery Billing block(LIKP-FAKSK) field based on certain condition through program instead of VL02N Tcode.
As LIKP-FAKSK is not available in BAPI’s parameter and instead of using direct modify statement which may cause of inconsistency between tables, BAPI will be used to update document consistently.
The Deployment Logic
The step that needs to be followed is as below.
- Go to Se 38 , Create a Custom Program like ZDELIVERY_UPDATE .
Define in data definition.
DATA :ls_bapiobdlvhdrchg TYPE bapiobdlvhdrchg,
ls_bapiobdlvhdrctrlchg TYPE bapiobdlvhdrctrlchg,
lt_bapireturn type STANDARD TABLE OF bapiret2,
lv_FAKSK type FAKSK ,
FLG_BAPI_ERROR type Flag .
- Define Selection screen with delivery number and bill block(field FAKSK – To be update through BAPI)
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_VBELN type VBELN_NACH,
p_FAKSK TYPE FAKSK .
SELECTION-SCREEN END OF BLOCK b1..
- Export memory ID
lv_FAKSK = p_FAKSK.
export lv_FAKSK to memory id 'ZLIKP'.
- Call BAPI ‘BAPI_OUTB_DELIVERY_CHANGE’ to update header billing block
With Required parameter Delivery number as Billing block(FAKSK) field is not available in any parameter of BAPI that why exported to memory id in previous step.
ls_bapiobdlvhdrchg-DELIV_NUMB = p_VBELN .
ls_bapiobdlvhdrctrlchg-DELIV_NUMB = p_VBELN .
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
header_data = ls_bapiobdlvhdrchg
header_control = ls_bapiobdlvhdrctrlchg
delivery = p_VBELN
return = lt_bapireturn .
if lt_bapireturn is not initial.
call function 'BAPI_TRANSACTION_COMMIT'
wait = 'X'.
- Go to Include MV50AFZ1 under FORM “USEREXIT_SAVE_DOCUMENT_PREPARE” which call before updating Delivery document either from BAPI or from Screen.
Write code here either directly in form or with implicit Enhancement in the form.
Import Memroy ID and then just update internal Table XLIKP with corresponding field value which will used to update DB Table LIKP.
DATA : lv_FAKSK type FAKSK.
if ( xlikp-vbtyp = 'J' OR xlikp-vbtyp = 'T' ) and t180-trtyp = 'V'.
import lv_FAKSK from MEMORY ID 'ZLIKP'.
if sy-subrc is initial and not lv_FAKSK is initial .
LOOP AT xlikp.
xlikp-FAKSK = lv_FAKSK.
MODIFY xlikp transporting FAKSK .
free MEMORY ID 'ZLIKP'.
Delivery document will be successfully updated.
Go to Se16 and check for LIKP table with your document number and check field value is updated with new value.
This code could be used to update Delivery document with BAPI whenever some fields are not available in BAPI’s Passing parameter.
|Objective of this white paper
Standard process to be followed during updating of Delivery document.Which will update corresponding tables with required checks.
Re-usability of efforts is key to deliver more in short time to reduce the turn around time in Project management.