By this point OB is already decided for splitting and all validation has happened.
We want to skip the validations and change the Partner numbers.
REMEMEBER: Mandatory partners determined by the TPAER table cannot be changed. Actaully it can be changed but system hangs while ceration of the Delv since it tries to delete the partner from VLPMA table.
Here READ_TEXT is reading the partner numbers passed from the custom Report to generate OB:
DATA: lt_range TYPE TABLE OF zrange.
FIELD-SYMBOLS: TYPE zrange,
LIKE xvbpa.
DATA: lv_name TYPE tdobname,
lt_lines TYPE STANDARD TABLE OF tline,
ls_lines LIKE LINE OF lt_lines,
ls_lips TYPE lips,
lv_ebelp TYPE ebelp.
CONSTANTS: co_savelang TYPE thead-tdspras VALUE 'E'.
* check for availability of PO doc
IF ekko-ebeln IS INITIAL.
RETURN.
ENDIF.
* Read ZRANGE for triggering of below logic
SELECT * FROM zrange INTO TABLE lt_range
WHERE application = 'HUBSTOSA' AND
program_name = 'MV50AFZ1' AND
identifier = ekko-ekorg.
IF sy-subrc EQ 0.
SORT lt_range BY fieldname.
"Check doc type
READ TABLE lt_range ASSIGNING WITH KEY fieldname = 'LFART' BINARY SEARCH.
IF sy-subrc NE 0 AND IS NOT ASSIGNED.
RETURN.
ELSEIF IS ASSIGNED.
IF-low NE likp-lfart.
RETURN.
ENDIF.
ENDIF.
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 ekko-bsart.
RETURN.
ENDIF.
ENDIF.
ELSE.
RETURN.
ENDIF.
CHECK sy-tcode EQ 'ZSD_SCHEDULE_HUB' OR sy-batch EQ 'X'.
READ TABLE xvbpa[] ASSIGNING WITH KEY parvw = 'ZB'."during change this Partner will be there
IF sy-subrc EQ 0.
RETURN."it means this code has been called during DN creation time. We need thi code during DN change
ENDIF.
********* Read Text *********
SORT xlips[] BY vgpos."text ID will always be there for the 1st item of the delivery as per Report logic
READ TABLE xlips[] INTO ls_lips INDEX 1.
MOVE ls_lips-vgpos+1(5) TO lv_ebelp.
IF sy-subrc EQ 0.
MOVE ls_lips-vgbel TO lv_name.
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 1.
IF sy-subrc EQ 0.
"Loop has been used here, so that in case of data issues, when multiple
"DNs are created, all DN should have the HUB Partner number
LOOP AT xvbpa[] ASSIGNING WHERE parvw = 'WE'.
MOVE ls_lines-tdline TO-kunnr.
SELECT adrnr UP TO 1 ROWS INTO-adrnr
FROM kna1 WHERE kunnr =-kunnr.
ENDSELECT.
ENDLOOP.
ENDIF.
ENDIF.
We want to skip the validations and change the Partner numbers.
REMEMEBER: Mandatory partners determined by the TPAER table cannot be changed. Actaully it can be changed but system hangs while ceration of the Delv since it tries to delete the partner from VLPMA table.
Here READ_TEXT is reading the partner numbers passed from the custom Report to generate OB:
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_ebelp TYPE ebelp.
CONSTANTS: co_savelang TYPE thead-tdspras VALUE 'E'.
* check for availability of PO doc
IF ekko-ebeln IS INITIAL.
RETURN.
ENDIF.
* Read ZRANGE for triggering of below logic
SELECT * FROM zrange INTO TABLE lt_range
WHERE application = 'HUBSTOSA' AND
program_name = 'MV50AFZ1' AND
identifier = ekko-ekorg.
IF sy-subrc EQ 0.
SORT lt_range BY fieldname.
"Check doc type
READ TABLE lt_range ASSIGNING
IF sy-subrc NE 0 AND
RETURN.
ELSEIF
IF
RETURN.
ENDIF.
ENDIF.
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'.
READ TABLE xvbpa[] ASSIGNING
IF sy-subrc EQ 0.
RETURN."it means this code has been called during DN creation time. We need thi code during DN change
ENDIF.
********* Read Text *********
SORT xlips[] BY vgpos."text ID will always be there for the 1st item of the delivery as per Report logic
READ TABLE xlips[] INTO ls_lips INDEX 1.
MOVE ls_lips-vgpos+1(5) TO lv_ebelp.
IF sy-subrc EQ 0.
MOVE ls_lips-vgbel TO lv_name.
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 1.
IF sy-subrc EQ 0.
"Loop has been used here, so that in case of data issues, when multiple
"DNs are created, all DN should have the HUB Partner number
LOOP AT xvbpa[] ASSIGNING
MOVE ls_lines-tdline TO
SELECT adrnr UP TO 1 ROWS INTO
FROM kna1 WHERE kunnr =
ENDSELECT.
ENDLOOP.
ENDIF.
ENDIF.
No comments:
Post a Comment