FM WS_LM_CHANGE_DLV_DISTRIB_STATE
ENHANCEMENT 1 YDISTRIBUTE. if ( sy-tcode eq 'VL06I' or sy-tcode eq 'VL06ID' ) and ( if_d_proctype eq proctype_inbdist ). "VL06I - do not process the enhancement if it distributes via other ways" "proctype_inbdist - checking only inbound deliveries" types: begin of t_params, paramval like yparamconst-paramval, end of t_params. data: lt_params type standard table of t_params, wa_params like line of lt_params, "work area (header line)" is_zles type boolean. "default abap_false." "which delivery types for checking/processing are defined in our Z-table?" select paramval from yparamconst into corresponding fields of table lt_params where paramid = 'LIEFERUNGSNUMMER'. if sy-subrc eq 0. field-symbols: <ls_lfart> type lipov. loop at ct_worktab assigning <ls_lfart>. read table lt_params with key paramval = <ls_lfart>-lfart transporting no fields. if sy-subrc eq 0. is_zles = abap_true. "all the selected delivery [types] are in yparamconst" endif. endloop. if is_zles eq abap_true. data: lt_wahl like gs_select occurs 0 with header line, begin of lt_wahl2 occurs 0, vbeln like likp-vbeln, verur like likp-verur, end of lt_wahl2, l_msg type c length 50, ans type char1. field-symbols: <ls_arbeit> type lipov, <ls_wahl2> like line of lt_wahl2. loop at ct_worktab assigning <ls_arbeit>. lt_wahl-vbeln = <ls_arbeit>-vbeln. collect lt_wahl. endloop. check not lt_wahl[] is initial. select vbeln verur from likp into table lt_wahl2 for all entries in lt_wahl where vbeln eq lt_wahl-vbeln. "in addition we checking if the field External ID isn't empty" loop at lt_wahl2 transporting no fields where verur eq space. endloop. if sy-subrc eq 0. message s000(Y_YSD) into l_msg. call function 'POPUP_TO_CONFIRM' exporting titlebar = 'Confirm' text_question = l_msg text_button_1 = 'Yes' text_button_2 = 'No' display_cancel_button = '' default_button = '2' importing answer = ans. if ans eq 2. return. endif. endif. clear l_msg. field-symbols: <ls_vepo> type lipov. data lt_vepo like VEPO occurs 0. loop at ct_worktab assigning <ls_vepo>. select vbeln from vepo into corresponding fields of table lt_vepo where vbeln eq <ls_vepo>-vbeln. if sy-subrc ne 0. message s001(Y_YSD) into l_msg. call function 'POPUP_TO_CONFIRM' exporting titlebar = 'Confirm' text_question = l_msg text_button_1 = 'Yes' text_button_2 = 'No' display_cancel_button = '' default_button = '2' importing answer = ans. if ans eq 2. return. endif. endif. endloop. endif. "is_zles" endif. endif. ENDENHANCEMENT.