In EWM Documents are one of the main objects which we always need to access through our custom developments. There are different types of Documents which most of them you can already see in the famous /SCWM/MON – Warehouse Management Monitor.
For each document type there is also a corresponding Object Manager Class which is dedicated to all kinds of operations on the related document type.
Here is a small code snippet about how to query an Inbound delivery document with the corresponding ASN number. It can be easily adjustable up to your needs.
" search with ASN code
DATA(lt_selection) = VALUE /scwm/dlv_selection_tab(
( fieldname = /scdl/if_dl_logfname_c=>sc_refdocno_asn_h
option = /scmb/cl_search=>sc_eq
sign = /scmb/cl_search=>sc_sign_i
low = me->docno_asn ) ) .
DATA(lo_prd) = NEW /scwm/cl_dlv_management_prd( ).
lo_prd->query( EXPORTING it_selection = lt_selection
iv_doccat = /scdl/if_dl_doc_c=>sc_doccat_inb_prd
is_read_options = VALUE #( data_retrival_only = abap_true )
is_include_data = VALUE #( head_partyloc = abap_true
item_partyloc = abap_true )
IMPORTING et_headers = DATA(lt_headers)
et_items = DATA(lt_items) ).
header = lt_headers.
items = lt_items.
CATCH cx_root. "#EC NO_HANDLER