Enhance Inbound Delivery Monitor with Identification Fields (/SCWM/MON)
Step 1: Run the T-code SPRO to check the FM.
Step 2: Click on SAP ref IMG. Expand SCM Extended Warehouse Management - Extended Warehouse Management - Monitoring - Warehouse Management Monitor.
Step 3: Execute Customize Monitor Tree. Expand Inbound and double click on Inbound delivery.
Step 4: Note the Node Profile and go back.
Step 5: Execute Define Nodes. Double clicks on Define node profiles.
Step 6: Click on Position and give Node and press enter.
* In this able to change FM, Structure, Program.
Step 7: Create a structure and table table. Check what ever the table type is assigned in fm(ET_DATA).
* After copy add custom fields in Structure.
* Z575TT_INB_DEL_HEAD
Step 8: Create a function group- Z575_FG_INB_DEL_HEAD.
Step 9: Run the T Code SE37 and give FM - /SCWM/WHRHEAD_MON Click on copy. Give Z function module name, Give created Function group(Z575_FG_INB_DEL_HEAD).
Step 9: Change ET_DATA type to custom table type and add logic for custom fields.
Step 10: Check all performs are implemented or not. Implement the Performs.
Step 11: Write the logic for custom fields .
FUNCTION z575_fm_mon_inb_del_head.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IV_LGNUM) TYPE /SCWM/LGNUM DEFAULT '0001'
*" REFERENCE(IV_VARIANT) TYPE VARIANT OPTIONAL
*" REFERENCE(IV_MODE) TYPE /SCWM/DE_MON_FM_MODE DEFAULT '1'
*" REFERENCE(IV_KEYS_ONLY) TYPE BOOLE_D OPTIONAL
*" EXPORTING
*" REFERENCE(EV_RETURNCODE) TYPE XFELD
*" REFERENCE(EV_VARIANT) TYPE VARIANT
*" REFERENCE(ET_DATA) TYPE Z575TT_INB_DEL_HEAD
*" REFERENCE(ET_KEY) TYPE /SCWM/DLV_DOCID_TAB
*" CHANGING
*" REFERENCE(CT_TAB_RANGE) TYPE RSDS_TRANGE OPTIONAL
*" REFERENCE(CT_FIELDCAT) TYPE LVC_T_FCAT OPTIONAL
*" RAISING
*" /SCWM/CX_MON_NOEXEC
*"----------------------------------------------------------------------
DATA:
lv_counter TYPE i,
lt_docid_tunum TYPE tty_docid_tu,
ls_docid_tunum TYPE ty_docid_tu,
lt_docid_vehnum TYPE tty_docid_veh,
ls_docid_vehnum TYPE ty_docid_veh,
ls_status_stm TYPE /scdl/stm_status_str,
ls_status_text TYPE /scdl/stm_status_text_str,
lt_mapping TYPE /scwm/tt_map_selopt2field,
ls_timedate TYPE /scwm/s_tstmp_date_time,
lt_tu TYPE /scwm/tt_bo_tu_data_dlv,
ls_tu TYPE /scwm/s_bo_tu_data,
* Declarations for query
lo_prd TYPE REF TO /scwm/cl_dlv_management_prd,
lv_door_set TYPE abap_bool,
lv_up_set TYPE abap_bool,
lv_no_item TYPE int4,
lv_no_product TYPE int4,
lv_unload_point TYPE /scdl/dl_locationno,
lv_door TYPE /scwm/de_door,
lv_productid TYPE /scdl/dl_productid,
lt_head TYPE /scwm/dlv_header_out_prd_tab,
lt_head_pack TYPE /scwm/dlv_header_out_prd_tab,
ls_head TYPE /scwm/dlv_header_out_prd_str,
ls_item TYPE /scwm/dlv_item_out_prd_str,
lt_item TYPE /scwm/dlv_item_out_prd_tab,
lt_item_pack TYPE /scwm/dlv_item_out_prd_tab,
lt_docid TYPE /scwm/dlv_docid_item_tab,
lt_docid_reject TYPE /scwm/dlv_docid_item_tab,
ls_docid TYPE /scwm/dlv_docid_item_str,
lt_typ_txt_pack TYPE /scwm/dlv_doctype_text_tab,
lt_doctype_txt TYPE /scwm/dlv_doctype_text_tab,
ls_doctype_txt TYPE /scwm/dlv_doctype_text_str,
lt_aggr_temp TYPE /scwm/tt_wip_whr_aggr,
lt_aggr TYPE /scwm/tt_wip_whr_aggr,
ls_aggr TYPE /scwm/s_wip_whr_aggr,
lt_aggr2 TYPE /scwm/tt_wip_whr_aggr2,
ls_aggr2 TYPE /scwm/s_wip_whr_aggr2,
lt_aggr3 TYPE /scwm/tt_wip_whr_aggr3,
ls_aggr3 TYPE /scwm/s_wip_whr_aggr3,
ls_date TYPE /scdl/dl_date_str,
ls_partyloc TYPE /scdl/dl_partyloc_str,
ls_transport TYPE /scdl/dl_transport_str,
lt_dynamic TYPE /scwm/t_sp_a_head_dynamic,
ls_dynamic TYPE /scwm/s_sp_a_head_dynamic,
ls_refdoc TYPE /scdl/dl_refdoc_str,
ls_status TYPE /scdl/dl_status_str,
lt_selection TYPE /scwm/dlv_selection_tab,
ls_read_options TYPE /scwm/dlv_query_contr_str,
ls_include_data TYPE /scwm/dlv_query_incl_str_prd,
ls_exclude_data TYPE /scwm/dlv_query_excl_str,
ls_key TYPE /scwm/dlv_docid_str,
lt_sel_add TYPE /scwm/dlv_selection_tab, " selection parameters which are NOT DOCID_H
lt_sel_docid TYPE /scwm/dlv_selection_tab, " selection parameters which are DOCID_H
lv_finished TYPE abap_bool.
" Start of change AVARIKA | 08.12.2025 | EWM Dubai changes.
DATA: lt_huhigh TYPE /scwm/tt_huhdr_int,
lt_huident TYPE /scwm/tt_ident_int,
lt_docid1 TYPE /scwm/tt_docid,
lr_docid1 TYPE /scwm/s_docid,
ls_whrhead TYPE z575s_inb_del_head.
" END of change AVARIKA | 08.12.2025 | EWM Dubai changes.
FIELD-SYMBOLS:
<ls_head> TYPE /scwm/dlv_header_out_prd_str,
<ls_selection> TYPE /scwm/dlv_selection_str.
CONSTANTS:
lc_dynnr TYPE sydynnr VALUE '0100',
lc_package_size TYPE i VALUE 10000.
* If iv_mode = 3 -> display only popup and exit ------------------------
IF iv_mode = 3.
CALL FUNCTION 'RS_VARIANT_CATALOG'
EXPORTING
report = sy-repid
* NEW_TITLE = ' '
dynnr = lc_dynnr
* POP_UP = ' '
IMPORTING
sel_variant = ev_variant
EXCEPTIONS
no_report = 1
report_not_existent = 2
report_not_supplied = 3
no_variants = 4
no_variant_selected = 5
variant_not_existent = 6
OTHERS = 99.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
RETURN.
ENDIF.
* Initialization -------------------------------------------------------
PERFORM initialization
USING sy-repid
CHANGING et_data.
* Fill mapping table ---------------------------------------------------
PERFORM whrhead_mapping CHANGING lt_mapping.
p_lgnum = iv_lgnum.
IF NOT iv_variant IS INITIAL.
* Use the selection criteria from a pre-defined variant without
* presenting a selection screen
CALL FUNCTION 'RS_SUPPORT_SELECTIONS'
EXPORTING
report = sy-repid
variant = iv_variant
EXCEPTIONS
variant_not_existent = 1
variant_obsolete = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
IF ct_tab_range IS NOT INITIAL.
* the table it_tab_range contains the selection criteria, which
* have been passed to the function module
* these selection criteria should be visible in the selection screen
CALL FUNCTION '/SCWM/RANGETAB2SELOPT'
EXPORTING
iv_repid = sy-repid
iv_lgnum = iv_lgnum
it_mapping = lt_mapping
CHANGING
ct_tab_range = ct_tab_range.
ENDIF.
* Move warehouse number into selection parameter for F4-Help
p_lgnum = iv_lgnum.
IF iv_mode = '1'.
* show selection screen and use the selection criteria entered on
* the screen. This screen can also be used for definition of a
* variant (standard functionality of selection-screens)
CALL SELECTION-SCREEN lc_dynnr STARTING AT 10 10
ENDING AT 130 30.
IF sy-subrc IS NOT INITIAL.
ev_returncode = abap_true.
RETURN.
ENDIF.
ENDIF.
* Convert parameter to time stamps -------------------------------------
PERFORM convert_date_time USING iv_lgnum
p_tudfr p_tutfr
p_tudto p_tutto
CHANGING s_tudt[].
PERFORM convert_date_time USING iv_lgnum
p_dlvdfr p_dlvtfr
p_dlvdto p_dlvtto
CHANGING s_dlvdt[].
PERFORM convert_date_time USING iv_lgnum
p_cdatfr p_ctimfr
p_cdatto p_ctimto
CHANGING s_cdat[].
* Export selection criteria --------------------------------------------
CALL FUNCTION '/SCWM/SELOPT2RANGETAB'
EXPORTING
iv_repid = sy-repid
it_mapping = lt_mapping
IMPORTING
et_tab_range = ct_tab_range.
* Two cases are possible now: we return only keys for external callers like WT/WO node
* or return the complete ID data
IF iv_keys_only IS NOT INITIAL.
ls_read_options-keys_only = abap_true.
ELSE.
ls_read_options-keys_only = abap_false.
* Fill exclude structure -----------------------------------------------
CLEAR ls_include_data.
ls_include_data-head_partyloc = abap_true.
ls_include_data-head_date = abap_true.
ls_include_data-head_status = abap_true.
* Calculate blocked status in all cases
ls_include_data-head_status_dyn
= /scwm/if_dl_c=>sc_h_stat_dyn_calc_all_items.
APPEND /scdl/if_dl_status_c=>sc_t_blocked_overall
TO ls_include_data-head_status_dyn_detail.
* If end user needs the dynamic statuses
IF p_cdyns IS INITIAL.
* For correct status calculation of DWA we need all related status added
APPEND /scdl/if_dl_status_c=>sc_t_warehouse_activity
TO ls_include_data-head_status_dyn_detail.
APPEND /scdl/if_dl_status_c=>sc_t_planning_unloading
TO ls_include_data-head_status_dyn_detail.
APPEND /scdl/if_dl_status_c=>sc_t_planning_putaway
TO ls_include_data-head_status_dyn_detail.
APPEND /scdl/if_dl_status_c=>sc_t_goods_receipt
TO ls_include_data-head_status_dyn_detail.
APPEND /scdl/if_dl_status_c=>sc_t_putaway
TO ls_include_data-head_status_dyn_detail.
APPEND /scdl/if_dl_status_c=>sc_t_split
TO ls_include_data-head_status_dyn_detail.
APPEND /scdl/if_dl_status_c=>sc_t_unloading
TO ls_include_data-head_status_dyn_detail.
APPEND /scwm/if_dl_qm_status_c=>sc_t_qi_execution
TO ls_include_data-head_status_dyn_detail.
APPEND /scwm/if_dl_status_c=>sc_t_vas
TO ls_include_data-head_status_dyn_detail.
APPEND /scdl/if_dl_status_c=>sc_t_goods_receipt_dist
TO ls_include_data-head_status_dyn_detail.
APPEND /scdl/if_dl_status_c=>sc_t_unloading_dist
TO ls_include_data-head_status_dyn_detail.
APPEND /scdl/if_dl_status_c=>sc_t_plan_unload_dist
TO ls_include_data-head_status_dyn_detail.
APPEND /scdl/if_dl_status_c=>sc_t_plan_putaway_dist
TO ls_include_data-head_status_dyn_detail.
APPEND /scdl/if_dl_status_c=>sc_t_putaway_dist
TO ls_include_data-head_status_dyn_detail.
ENDIF.
ls_include_data-head_refdoc = abap_true.
ls_include_data-head_transport = abap_true.
ls_include_data-item_partyloc = abap_true.
ls_include_data-item_date = abap_true.
* read item reference documents if requested
IF p_refdoc = abap_true.
ls_include_data-item_refdoc = abap_true.
ENDIF.
* Restrict document flow to 1 level ------------------------------------
ls_read_options-docflow_succ_1level_only = abap_true.
ls_read_options-data_retrival_only = abap_true.
* Partner texts
ls_read_options-mdctrl-text = abap_true.
ENDIF.
* Fill selection table -------------------------------------------------
PERFORM fill_selection_table USING iv_lgnum
CHANGING lt_selection.
* Adjust selection table for wildcard searches -------------------------
/scwm/cl_dlv_ui_services=>modify_wildcard_selections(
CHANGING ct_selections_prd = lt_selection ).
* It might happen that there was a preceeding selection for DOCIDs e.g.
* TU/HU/wave assignment pre-filter. In this case we might get a huge amount of
* individual DOCID_H selections which can lead to an exception in DB level
* due to the long selection (DBSQL_STMNT_TOO_LARG)
* How to avoid it: first collect logical fieldnames which are not DOCID_H.
* These should be added to the DOCID_H package at each QUERY call.
CLEAR lt_sel_add.
LOOP AT lt_selection ASSIGNING <ls_selection>.
IF <ls_selection>-fieldname = 'DOCID_H' AND
<ls_selection>-option = 'EQ'.
APPEND <ls_selection> TO lt_sel_docid.
ELSE.
APPEND <ls_selection> TO lt_sel_add.
ENDIF.
ENDLOOP.
lo_prd = /scwm/cl_dlv_management_prd=>get_instance( ).
SORT lt_sel_docid BY low.
CLEAR lv_finished.
WHILE NOT lv_finished = abap_true.
CLEAR lt_selection.
LOOP AT lt_sel_docid ASSIGNING <ls_selection> TO lc_package_size.
APPEND <ls_selection> TO lt_selection.
ENDLOOP.
DELETE lt_sel_docid TO lc_package_size.
* Add the remaining non DOCID-H selections to the range
APPEND LINES OF lt_sel_add TO lt_selection.
* Select data ----------------------------------------------------------
TRY.
lo_prd->query(
EXPORTING it_selection = lt_selection
iv_doccat = /scdl/if_dl_doc_c=>sc_doccat_inb_prd
is_read_options = ls_read_options
is_include_data = ls_include_data
IMPORTING et_headers = lt_head_pack
et_items = lt_item_pack
et_doctype_texts = lt_typ_txt_pack ).
CATCH /scdl/cx_delivery. "#EC NO_HANDLER
ENDTRY.
APPEND LINES OF lt_head_pack TO lt_head.
APPEND LINES OF lt_item_pack TO lt_item.
* The LT_DOCTYPE_TXT table is sorted by DDIC by keys DOCCAT and DOCTYPE
LOOP AT lt_typ_txt_pack INTO ls_doctype_txt.
READ TABLE lt_doctype_txt WITH TABLE KEY doccat = ls_doctype_txt-doccat
doctype = ls_doctype_txt-doctype TRANSPORTING NO FIELDS.
IF sy-subrc <> 0.
INSERT ls_doctype_txt INTO lt_doctype_txt INDEX sy-tabix.
ENDIF.
ENDLOOP.
CLEAR: lt_head_pack,
lt_item_pack,
lt_typ_txt_pack.
IF lt_sel_docid IS INITIAL.
lv_finished = abap_true.
ENDIF.
ENDWHILE.
* Check result ---------------------------------------------------------
IF lt_head IS INITIAL.
REFRESH et_data.
RETURN.
ENDIF.
* in case of rejection, read additional data and filter out not matching headers
IF p_rejdet = abap_true OR p_rejsel = abap_true.
CLEAR lt_docid.
CLEAR lt_docid_reject.
LOOP AT lt_head ASSIGNING <ls_head>.
CLEAR ls_docid.
ls_docid-doccat = <ls_head>-doccat.
ls_docid-docid = <ls_head>-docid.
APPEND ls_docid TO lt_docid.
ENDLOOP.
* read and check rejected deliveries
IF lt_docid IS NOT INITIAL.
/scwm/cl_dlv_db_select=>select_rejected_h(
EXPORTING it_docid = lt_docid
IMPORTING et_docid_rejected = lt_docid_reject ).
SORT lt_docid_reject BY docid.
ENDIF.
* in case that only rejected deliveries shall be returned, filter out all non rejected ones
IF p_rejsel = abap_true.
LOOP AT lt_head ASSIGNING <ls_head>.
READ TABLE lt_docid_reject TRANSPORTING NO FIELDS WITH KEY
docid = <ls_head>-docid BINARY SEARCH.
IF sy-subrc <> 0.
DELETE lt_head.
CONTINUE.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
IF iv_keys_only IS INITIAL.
* Get status management instance ---------------------------------------
IF go_stm IS INITIAL.
TRY.
go_stm = /scdl/cl_stm=>get_instance( ).
CATCH /scdl/cx_stm. "#EC NO_HANDLER
ENDTRY.
ENDIF.
* Get aggregation data -------------------------------------------------
REFRESH s_docid.
REFRESH s_docid2.
s_docid-sign = 'I'.
s_docid-option = 'EQ'.
s_docid2-sign = 'I'.
s_docid2-option = 'EQ'.
LOOP AT lt_head ASSIGNING <ls_head>.
lv_counter = lv_counter + 1.
s_docid-low = <ls_head>-docid.
APPEND s_docid.
s_docid2-low = <ls_head>-docid.
APPEND s_docid2.
IF lv_counter = gc_package_size.
* Package size for SELECTS reached, start SELECT
PERFORM select_huref CHANGING lt_aggr.
PERFORM select_tu CHANGING lt_docid_tunum.
PERFORM select_veh CHANGING lt_docid_vehnum.
REFRESH s_docid2.
lv_counter = 0.
ENDIF.
ENDLOOP.
* Select data for remaining DOCIDs
IF NOT s_docid2[] IS INITIAL.
PERFORM select_huref CHANGING lt_aggr.
PERFORM select_tu CHANGING lt_docid_tunum.
PERFORM select_veh CHANGING lt_docid_vehnum.
REFRESH s_docid2.
ENDIF.
* Items and products
CLEAR:
ls_timedate,
lv_no_item,
lv_no_product.
SORT lt_item BY docid product-productid.
LOOP AT lt_item INTO ls_item.
IF sy-tabix = 1.
* Execute only in first loop
ls_aggr2-docid = ls_item-docid.
IF p_refdoc = abap_true.
CLEAR ls_aggr3.
ls_aggr3-docid = ls_item-docid.
ENDIF.
ENDIF.
* Set aggregation data
IF ls_item-docid NE ls_aggr2-docid.
ls_aggr2-/scwm/door = lv_door.
ls_aggr2-/scwm/unloading_point = lv_unload_point.
ls_aggr2-no_item = lv_no_item.
ls_aggr2-no_product = lv_no_product.
ls_aggr2-gr_date_plan = ls_timedate-date.
ls_aggr2-gr_time_plan = ls_timedate-time.
APPEND ls_aggr2 TO lt_aggr2.
ls_aggr2-docid = ls_item-docid.
IF p_refdoc = abap_true.
APPEND ls_aggr3 TO lt_aggr3.
CLEAR ls_aggr3.
ls_aggr3-docid = ls_item-docid.
ENDIF.
lv_no_item = 1.
CLEAR:
ls_timedate,
lv_no_product,
lv_door,
lv_door_set,
lv_up_set,
lv_unload_point,
ls_partyloc,
lv_productid.
ELSE.
* Item counter
lv_no_item = lv_no_item + 1.
ENDIF.
* Set the planned GR date (only once per header)
IF ls_timedate-date IS INITIAL.
* Planned delivery date
READ TABLE ls_item-dates INTO ls_date
WITH KEY tsttype = /scdl/if_dl_c=>sc_tsttype_sgoodsreceipt
tst_category = /scdl/if_dl_c=>sc_tstcat_plan.
IF sy-subrc EQ 0.
PERFORM convert_timestamp USING ls_date-tstfr
iv_lgnum
CHANGING ls_timedate.
ENDIF.
ENDIF.
* Door
IF lv_door NE '***' AND ls_item-sapext-/scwm/door IS NOT INITIAL.
IF lv_door_set = abap_false.
lv_door = ls_item-sapext-/scwm/door.
lv_door_set = abap_true.
ENDIF.
IF lv_door NE ls_item-sapext-/scwm/door.
lv_door = '***'.
ENDIF.
ENDIF.
* Unloading point
IF lv_unload_point NE '***'.
READ TABLE ls_item-partyloc INTO ls_partyloc
WITH KEY party_role = /scdl/if_dl_partyloc_c=>sc_party_role_up.
IF sy-subrc NE 0.
CLEAR ls_partyloc-party_role.
ENDIF.
IF lv_up_set = abap_false.
lv_unload_point = ls_partyloc-locationno.
lv_up_set = abap_true.
ENDIF.
IF lv_unload_point NE ls_partyloc-locationno.
lv_unload_point = '***'.
ENDIF.
ENDIF.
* Product counter
IF NOT ls_item-product-productid IS INITIAL.
IF ls_item-product-productid NE lv_productid.
lv_no_product = lv_no_product + 1.
lv_productid = ls_item-product-productid.
ENDIF.
ENDIF.
IF p_refdoc = abap_true.
LOOP AT ls_item-refdoc INTO ls_refdoc.
CASE ls_refdoc-refdoccat.
* RMA number
WHEN /scwm/if_dl_c=>sc_doccat_rma.
IF ls_aggr3-rma_number_h NE ls_refdoc-refdocno AND
ls_aggr3-rma_number_h IS NOT INITIAL.
ls_aggr3-rma_number_h = '***'.
ELSE.
ls_aggr3-rma_number_h = ls_refdoc-refdocno.
ENDIF.
* Purchase order
WHEN /scdl/if_dl_c=>sc_doccat_inb_po.
IF ls_aggr3-po_number_h NE ls_refdoc-refdocno AND
ls_aggr3-po_number_h IS NOT INITIAL.
ls_aggr3-po_number_h = '***'.
ELSE.
ls_aggr3-po_number_h = ls_refdoc-refdocno.
ENDIF.
* Production order
WHEN /scwm/if_dl_c=>sc_doccat_ppo.
IF ls_aggr3-prod_order_h NE ls_refdoc-refdocno AND
ls_aggr3-prod_order_h IS NOT INITIAL.
ls_aggr3-prod_order_h = '***'.
ELSE.
ls_aggr3-prod_order_h = ls_refdoc-refdocno.
ENDIF.
* ERP document
WHEN /scwm/if_dl_c=>sc_doccat_erp.
IF ls_aggr3-erp_number_h NE ls_refdoc-refdocno AND
ls_aggr3-erp_number_h IS NOT INITIAL.
ls_aggr3-erp_number_h = '***'.
ELSE.
ls_aggr3-erp_number_h = ls_refdoc-refdocno.
ENDIF.
ENDCASE.
ENDLOOP.
ENDIF.
ENDLOOP.
* Set aggregation data for last loop ----------------------------------
ls_aggr2-/scwm/door = lv_door.
ls_aggr2-/scwm/unloading_point = lv_unload_point.
ls_aggr2-gr_date_plan = ls_timedate-date.
ls_aggr2-gr_time_plan = ls_timedate-time.
ls_aggr2-no_item = lv_no_item.
ls_aggr2-no_product = lv_no_product.
APPEND ls_aggr2 TO lt_aggr2.
IF p_refdoc = abap_true.
APPEND ls_aggr3 TO lt_aggr3.
ENDIF.
* Fill export table ----------------------------------------------------
LOOP AT lt_head ASSIGNING <ls_head>.
CLEAR ls_whrhead.
* Set head data
ls_whrhead-docid = <ls_head>-docid.
ls_whrhead-docno_h = <ls_head>-docno.
ls_whrhead-doctype = <ls_head>-doctype.
ls_whrhead-manual = <ls_head>-manual.
MOVE-CORRESPONDING <ls_head>-eew TO ls_whrhead.
READ TABLE lt_doctype_txt INTO ls_doctype_txt
WITH KEY doctype = <ls_head>-doctype.
ls_whrhead-doctype_txt = ls_doctype_txt-text.
READ TABLE <ls_head>-transport INDEX 1
INTO ls_transport.
IF sy-subrc = 0.
ls_whrhead-transmeans_id = ls_transport-transmeans_id.
ls_whrhead-transpl_type = ls_transport-transpl_type.
ls_whrhead-transmeans_type = ls_transport-transmeans_type.
ENDIF.
* Set vehicle data
LOOP AT lt_docid_vehnum INTO ls_docid_vehnum
WHERE docid = <ls_head>-docid.
IF ls_whrhead-transmeans_id IS INITIAL.
ls_whrhead-transmeans_id = ls_docid_vehnum-veh_num_ext.
ELSE.
ls_whrhead-transmeans_id = '***'.
EXIT.
ENDIF.
ENDLOOP.
* Set SAPEXT data
ls_whrhead-/scwm/priop = <ls_head>-sapext-/scwm/priop.
* Set reference document data
LOOP AT <ls_head>-refdoc INTO ls_refdoc.
CASE ls_refdoc-refdoccat.
* Bill of lading
WHEN /scdl/if_dl_c=>sc_doccat_bol.
ls_whrhead-bol_number = ls_refdoc-refdocno.
* ASN number
WHEN /scdl/if_dl_c=>sc_doccat_asn.
ls_whrhead-refdocno_extasn = ls_refdoc-refdocno.
* PRO number
WHEN /scwm/if_dl_c=>sc_doccat_pro.
ls_whrhead-pro_number = ls_refdoc-refdocno.
* TCD reference number
WHEN /scwm/if_dl_c=>sc_doccat_tcd.
ls_whrhead-tcd_ref_no = ls_refdoc-refdocno.
* FRD
WHEN /scdl/if_dl_doc_c=>sc_doccat_frd.
ls_whrhead-frd_num = ls_refdoc-refdocno.
ENDCASE.
ENDLOOP.
IF p_cdyns = abap_true.
ls_whrhead-status_wm_activity = TEXT-031.
ls_whrhead-status_putaway = TEXT-031.
ls_whrhead-status_putaway_plan = TEXT-031.
ls_whrhead-status_gr = TEXT-031.
ls_whrhead-status_unloading = TEXT-031.
ls_whrhead-status_goods_receipt_dist = TEXT-031.
ls_whrhead-status_unloading_dist = TEXT-031.
ls_whrhead-status_plan_unload_dist = TEXT-031.
ls_whrhead-status_plan_putaway_dist = TEXT-031.
ls_whrhead-status_putaway_dist = TEXT-031.
ENDIF.
* Set status data
LOOP AT <ls_head>-status INTO ls_status.
CASE ls_status-status_type.
WHEN /scdl/if_dl_c=>sc_t_in_yard.
ls_status_stm-status_type = /scdl/if_dl_c=>sc_t_in_yard.
ls_status_stm-status_value = ls_status-status_value.
PERFORM get_status_text USING ls_status_stm
CHANGING ls_status_text.
ls_whrhead-status_inyard = ls_status_text-status_value_text.
WHEN /scdl/if_dl_c=>sc_t_unloading.
ls_status_stm-status_type = /scdl/if_dl_c=>sc_t_unloading.
ls_status_stm-status_value = ls_status-status_value.
PERFORM get_status_text USING ls_status_stm
CHANGING ls_status_text.
ls_whrhead-status_unloading =
ls_status_text-status_value_text.
WHEN /scdl/if_dl_c=>sc_t_warehouse_activity.
ls_status_stm-status_type =
/scdl/if_dl_c=>sc_t_warehouse_activity.
ls_status_stm-status_value = ls_status-status_value.
PERFORM get_status_text USING ls_status_stm
CHANGING ls_status_text.
ls_whrhead-status_wm_activity =
ls_status_text-status_value_text.
WHEN /scdl/if_dl_c=>sc_t_goods_receipt.
ls_status_stm-status_type = /scdl/if_dl_c=>sc_t_goods_receipt.
ls_status_stm-status_value = ls_status-status_value.
PERFORM get_status_text USING ls_status_stm
CHANGING ls_status_text.
ls_whrhead-status_gr = ls_status_text-status_value_text.
WHEN /scdl/if_dl_c=>sc_t_putaway.
ls_status_stm-status_type = /scdl/if_dl_c=>sc_t_putaway.
ls_status_stm-status_value = ls_status-status_value.
PERFORM get_status_text USING ls_status_stm
CHANGING ls_status_text.
ls_whrhead-status_putaway = ls_status_text-status_value_text.
WHEN /scdl/if_dl_c=>sc_t_planning_putaway.
ls_status_stm-status_type =
/scdl/if_dl_c=>sc_t_planning_putaway.
ls_status_stm-status_value = ls_status-status_value.
PERFORM get_status_text USING ls_status_stm
CHANGING ls_status_text.
ls_whrhead-status_putaway_plan =
ls_status_text-status_value_text.
WHEN /scwm/if_dl_c=>sc_t_ncts.
ls_status_stm-status_type =
/scwm/if_dl_c=>sc_t_ncts.
ls_status_stm-status_value = ls_status-status_value.
PERFORM get_status_text USING ls_status_stm
CHANGING ls_status_text.
ls_whrhead-status_ncts = ls_status_text-status_value_text.
WHEN /scdl/if_dl_c=>sc_t_blocked_overall.
CALL FUNCTION '/SCWM/WIP_GET_DLV_STATUS_ICON'
EXPORTING
iv_status_type = /scdl/if_dl_c=>sc_t_blocked_overall
iv_status_value = ls_status-status_value
IMPORTING
ev_icon = ls_whrhead-status_blocked_overall.
WHEN /scdl/if_dl_status_c=>sc_t_goods_receipt_dist.
ls_status_stm-status_type = ls_status-status_type.
ls_status_stm-status_value = ls_status-status_value.
PERFORM get_status_text USING ls_status_stm
CHANGING ls_status_text.
ls_whrhead-status_goods_receipt_dist
= ls_status_text-status_value_text.
WHEN /scdl/if_dl_status_c=>sc_t_unloading_dist.
ls_status_stm-status_type = ls_status-status_type.
ls_status_stm-status_value = ls_status-status_value.
PERFORM get_status_text USING ls_status_stm
CHANGING ls_status_text.
ls_whrhead-status_unloading_dist
= ls_status_text-status_value_text.
WHEN /scdl/if_dl_status_c=>sc_t_plan_unload_dist.
ls_status_stm-status_type = ls_status-status_type.
ls_status_stm-status_value = ls_status-status_value.
PERFORM get_status_text USING ls_status_stm
CHANGING ls_status_text.
ls_whrhead-status_plan_unload_dist
= ls_status_text-status_value_text.
WHEN /scdl/if_dl_status_c=>sc_t_plan_putaway_dist.
ls_status_stm-status_type = ls_status-status_type.
ls_status_stm-status_value = ls_status-status_value.
PERFORM get_status_text USING ls_status_stm
CHANGING ls_status_text.
ls_whrhead-status_plan_putaway_dist
= ls_status_text-status_value_text.
WHEN /scdl/if_dl_status_c=>sc_t_putaway_dist.
ls_status_stm-status_type = ls_status-status_type.
ls_status_stm-status_value = ls_status-status_value.
PERFORM get_status_text USING ls_status_stm
CHANGING ls_status_text.
ls_whrhead-status_putaway_dist
= ls_status_text-status_value_text.
ENDCASE.
ENDLOOP.
* Set partyloc data
LOOP AT <ls_head>-partyloc INTO ls_partyloc.
CASE ls_partyloc-party_role.
* Receiving office
WHEN /scdl/if_dl_c=>sc_party_role_ro.
ls_whrhead-receiving_office = ls_partyloc-orgunitno.
* Carrier
WHEN /scdl/if_dl_c=>sc_party_role_carr.
ls_whrhead-carrier = ls_partyloc-partyno.
ls_whrhead-carrier_descr = ls_partyloc-party_text.
* Ship from party
WHEN /scdl/if_dl_c=>sc_party_role_sfprt.
ls_whrhead-ship_from_party = ls_partyloc-partyno.
ls_whrhead-ship_from_party_descr = ls_partyloc-party_text.
* Final ship to party
WHEN /scwm/if_dl_c=>sc_party_role_stprtf.
ls_whrhead-final_ship_to_party = ls_partyloc-partyno.
ls_whrhead-final_ship_to_party_descr = ls_partyloc-party_text.
* Ship from location
WHEN /scdl/if_dl_c=>sc_party_role_sflo.
ls_whrhead-ship_from_location = ls_partyloc-locationno.
ls_whrhead-ship_from_location_descr = ls_partyloc-location_text.
ENDCASE.
ENDLOOP.
* Set TU data
LOOP AT lt_docid_tunum INTO ls_docid_tunum
WHERE docid = <ls_head>-docid.
IF ls_whrhead-tu IS INITIAL.
ls_whrhead-tu = ls_docid_tunum-tu_num_ext.
ELSE.
ls_whrhead-tu = '***'.
EXIT.
ENDIF.
ENDLOOP.
* Set aggregation data
READ TABLE lt_aggr INTO ls_aggr
WITH KEY docid = <ls_head>-docid.
IF sy-subrc EQ 0.
ls_whrhead-no_hu = ls_aggr-no_hu.
ENDIF.
READ TABLE lt_aggr2 INTO ls_aggr2 WITH KEY docid = <ls_head>-docid.
IF sy-subrc EQ 0.
ls_whrhead-/scwm/door = ls_aggr2-/scwm/door.
ls_whrhead-/scwm/unloading_point = ls_aggr2-/scwm/unloading_point.
ls_whrhead-no_item = ls_aggr2-no_item.
ls_whrhead-no_product = ls_aggr2-no_product.
ls_whrhead-gr_date_plan = ls_aggr2-gr_date_plan.
ls_whrhead-gr_time_plan = ls_aggr2-gr_time_plan.
ENDIF.
IF p_refdoc = abap_true.
READ TABLE lt_aggr3 INTO ls_aggr3 WITH KEY docid = <ls_head>-docid.
IF sy-subrc EQ 0.
ls_whrhead-rma_number = ls_aggr3-rma_number_h.
ls_whrhead-po_number = ls_aggr3-po_number_h.
ls_whrhead-prod_order = ls_aggr3-prod_order_h.
ls_whrhead-erp_number = ls_aggr3-erp_number_h.
ENDIF.
ELSE.
ls_whrhead-rma_number = TEXT-032.
ls_whrhead-po_number = TEXT-032.
ls_whrhead-prod_order = TEXT-032.
ls_whrhead-erp_number = TEXT-032.
ENDIF.
* Planned delivery date
READ TABLE <ls_head>-dates INTO ls_date
WITH KEY tsttype = /scdl/if_dl_c=>sc_tsttype_delivery
tst_category = /scdl/if_dl_c=>sc_tstcat_plan.
IF sy-subrc EQ 0.
PERFORM convert_timestamp USING ls_date-tstfr
iv_lgnum
CHANGING ls_timedate.
ls_whrhead-dlv_date = ls_timedate-date.
ls_whrhead-dlv_time = ls_timedate-time.
ENDIF.
* Delivery creation date
IF <ls_head>-admin-cretst IS NOT INITIAL.
PERFORM convert_timestamp USING <ls_head>-admin-cretst
iv_lgnum
CHANGING ls_timedate.
ls_whrhead-tdelivery_cre_date = ls_timedate-date.
ls_whrhead-tdelivery_cre_time = ls_timedate-time.
ENDIF.
* Created By
ls_whrhead-created_by = <ls_head>-admin-creusr.
* Ship date
READ TABLE <ls_head>-dates INTO ls_date
WITH KEY tsttype = /scdl/if_dl_c=>sc_tsttype_outyard
tst_category = /scdl/if_dl_c=>sc_tstcat_plan.
IF sy-subrc EQ 0.
PERFORM convert_timestamp USING ls_date-tstfr
iv_lgnum
CHANGING ls_timedate.
ls_whrhead-ship_date = ls_timedate-date.
ls_whrhead-ship_time = ls_timedate-time.
ENDIF.
* rejected flag.
READ TABLE lt_docid_reject TRANSPORTING NO FIELDS WITH KEY
docid = <ls_head>-docid BINARY SEARCH.
IF sy-subrc = 0.
ls_whrhead-rejected = abap_true.
ELSEIF p_rejdet = abap_true OR p_rejsel = abap_true.
ls_whrhead-rejected = '-'. "false
ENDIF.
" Start of change AVARIKA | 08.12.2025 | EWM Dubai changes.
IF ls_whrhead-docid IS NOT INITIAL.
REFRESH : lt_docid1. CLEAR : lr_docid1.
lr_docid1-docid = ls_whrhead-docid.
APPEND lr_docid1 TO lt_docid1.
CALL FUNCTION '/SCWM/DLV_GET_HUS_FOR_DELIVERY'
EXPORTING
iv_doccat = 'PDI'
it_docid = lt_docid1 "ls_whrhead-docid
iv_lgnum = 'DB01'
IMPORTING
et_high = lt_huhigh
et_ident = lt_huident
EXCEPTIONS
error = 1
OTHERS = 2.
ENDIF.
IF lt_huident IS NOT INITIAL .
LOOP AT lt_huident INTO DATA(lr_huident).
CASE lr_huident-idart.
WHEN 'B'.
ls_whrhead-boe = lr_huident-huident.
WHEN 'N'.
ls_whrhead-dec_number = lr_huident-huident.
WHEN 'D'.
ls_whrhead-dec_date = lr_huident-huident.
WHEN 'L'.
ls_whrhead-lot_number = lr_huident-huident.
ENDCASE.
CLEAR : lr_huident.
ENDLOOP.
ENDIF.
" END of change AVARIKA | 08.12.2025 | EWM Dubai changes.
APPEND ls_whrhead TO et_data.
ENDLOOP.
ELSE.
* Fill export table only with key
LOOP AT lt_head INTO ls_head.
CLEAR ls_key.
ls_key-docid = ls_head-docid.
APPEND ls_key TO et_key.
ENDLOOP.
ENDIF.
* Cleanup
IF go_taman IS BOUND.
go_taman->cleanup( iv_lgnum = p_lgnum ).
ENDIF.
SORT et_data BY docno_h.
PERFORM whrhead_fieldcat_modify CHANGING ct_fieldcat.
ENDFUNCTION.
Testing:
* Run the T-code /SCWM/MON.
* Give Warehouse number and monitor.
* Expand Inbound and Double click on Inbound delivery.
* Execute.
******************************Thank you*******************************
Comments
Post a Comment