BADI and User exit for OB before even Delivery data checks starts.
- before delivery split criteria is determined.
- before sending data to GN_DELIVERY_CREATE
- changing data for OB created from STO - BAPI_OUTB_DELIVERY_CREATE_STO
Basic idea is to target the Delivery creation structure - it_komdlgn
inside GN_DELIVERY_CREATE at the beginning it self you have a BADI. But this BADI has all IMPORTING parameters for the Method - IMPORT. SO its not directly possible to change the data.
Use STACK table assignment using Field-symbols to change the data.
BADI - shp_badi_gn_delivery_create
Implementation:
IF_EX_SHP_GN_DELIVERY_CREATE~IMPORT
Requirement - to change the LFDAT field which is read from EKET table and Spitting of MATNR is done based on that.
METHOD if_ex_shp_gn_delivery_create~import.
DATA: lt_range TYPE TABLE OF zrange.
FIELD-SYMBOLS: TYPE zrange,
TYPE komdlgn,
TYPE ANY TABLE.
DATA: lv_name TYPE tdobname,
lt_lines TYPE STANDARD TABLE OF tline,
ls_lines LIKE LINE OF lt_lines,
ls_lips TYPE lips,
lv_ebeln TYPE ebeln,
lv_ekorg TYPE ekorg,
lv_bsart TYPE bsart,
lv_prog TYPE string VALUE '(SAPLV50S)XKOMDLGN[]'.
CONSTANTS: co_savelang TYPE thead-tdspras VALUE 'E'.
*** Dynamic accessing of variables in Stack programs
ASSIGN (lv_prog) TO.
CHECK IS ASSIGNED.
* Read table available in BADI to get SA num
READ TABLE xkomdlgn ASSIGNING INDEX 1.
CHECK sy-subrc EQ 0.
MOVE-vgbel TO lv_name."for READ_TEXT
MOVE-vgbel TO lv_ebeln."for SELECT query
* Get SA details for verification with ZRANGE table
SELECT ekorg bsart UP TO 1 ROWS INTO (lv_ekorg,lv_bsart)
FROM ekko
WHERE ebeln EQ lv_ebeln.
ENDSELECT.
* Read ZRANGE for triggering of below logic
SELECT * FROM zrange INTO TABLE lt_range
WHERE application = 'HUBSTOSA' AND
program_name = 'MV50AFZ1' AND
identifier = lv_ekorg.
IF sy-subrc EQ 0.
SORT lt_range BY fieldname.
READ TABLE lt_range ASSIGNING WITH KEY fieldname = 'BSART' BINARY SEARCH.
IF sy-subrc NE 0 AND IS NOT ASSIGNED.
RETURN.
ELSEIF IS ASSIGNED.
IF-low NE lv_bsart.
RETURN.
ENDIF.
ENDIF.
ELSE.
RETURN.
ENDIF.
*
CHECK sy-tcode EQ 'ZSD_SCHEDULE_HUB' OR sy-batch EQ 'X'.
*
CALL FUNCTION 'READ_TEXT'
EXPORTING
* client = sy-mandt
id = 'L04'
language = co_savelang
name = lv_name
object = 'EKPO'
TABLES
lines = lt_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
RETURN.
ENDIF.
READ TABLE lt_lines INTO ls_lines INDEX 2.
LOOP AT ASSIGNING .
MOVE ls_lines-tdline TO-lfdat.
ENDLOOP.
ENDMETHOD.
- before delivery split criteria is determined.
- before sending data to GN_DELIVERY_CREATE
- changing data for OB created from STO - BAPI_OUTB_DELIVERY_CREATE_STO
Basic idea is to target the Delivery creation structure - it_komdlgn
inside GN_DELIVERY_CREATE at the beginning it self you have a BADI. But this BADI has all IMPORTING parameters for the Method - IMPORT. SO its not directly possible to change the data.
Use STACK table assignment using Field-symbols to change the data.
BADI - shp_badi_gn_delivery_create
Implementation:
IF_EX_SHP_GN_DELIVERY_CREATE~IMPORT
Requirement - to change the LFDAT field which is read from EKET table and Spitting of MATNR is done based on that.
METHOD if_ex_shp_gn_delivery_create~import.
DATA: lt_range TYPE TABLE OF zrange.
FIELD-SYMBOLS:
DATA: lv_name TYPE tdobname,
lt_lines TYPE STANDARD TABLE OF tline,
ls_lines LIKE LINE OF lt_lines,
ls_lips TYPE lips,
lv_ebeln TYPE ebeln,
lv_ekorg TYPE ekorg,
lv_bsart TYPE bsart,
lv_prog TYPE string VALUE '(SAPLV50S)XKOMDLGN[]'.
CONSTANTS: co_savelang TYPE thead-tdspras VALUE 'E'.
*** Dynamic accessing of variables in Stack programs
ASSIGN (lv_prog) TO
CHECK
* Read table available in BADI to get SA num
READ TABLE xkomdlgn ASSIGNING
CHECK sy-subrc EQ 0.
MOVE
MOVE
* Get SA details for verification with ZRANGE table
SELECT ekorg bsart UP TO 1 ROWS INTO (lv_ekorg,lv_bsart)
FROM ekko
WHERE ebeln EQ lv_ebeln.
ENDSELECT.
* Read ZRANGE for triggering of below logic
SELECT * FROM zrange INTO TABLE lt_range
WHERE application = 'HUBSTOSA' AND
program_name = 'MV50AFZ1' AND
identifier = lv_ekorg.
IF sy-subrc EQ 0.
SORT lt_range BY fieldname.
READ TABLE lt_range ASSIGNING
IF sy-subrc NE 0 AND
RETURN.
ELSEIF
IF
RETURN.
ENDIF.
ENDIF.
ELSE.
RETURN.
ENDIF.
*
CHECK sy-tcode EQ 'ZSD_SCHEDULE_HUB' OR sy-batch EQ 'X'.
*
CALL FUNCTION 'READ_TEXT'
EXPORTING
* client = sy-mandt
id = 'L04'
language = co_savelang
name = lv_name
object = 'EKPO'
TABLES
lines = lt_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
RETURN.
ENDIF.
READ TABLE lt_lines INTO ls_lines INDEX 2.
LOOP AT
MOVE ls_lines-tdline TO
ENDLOOP.
ENDMETHOD.
No comments:
Post a Comment