on 2020 Nov 03 12:34 PM
I want to determine a delivery document of a specific document category (doccat) by a production order document number (refdocno) via class /SCWM/CL_DLV_MANAGEMENT_PRD and method query.
Currently I can only achieve this by two selects without using method query:
SELECT SINGLE *
FROM /scdl/db_proch_p AS a
JOIN /scdl/db_refdoc AS b ON a~docid = b~docid
WHERE b~refdoccat EQ @doccat_ppo
AND b~refdocno EQ @iv_prod_order
INTO @DATA(ls_proch_p).
es_doc_hdr = ls_proch_p-a.
IF es_doc_hdr IS INITIAL.
RETURN.
ENDIF.
SELECT *
FROM /scdl/db_proci_p
WHERE docid EQ @es_doc_hdr-docid
INTO TABLE @et_doc_itm.
I tried it the following way, but get no results:
DATA(lt_selection) = VALUE /scwm/dlv_selection_tab( ( fieldname = 'REFDOCCAT_I'
sign = 'I'
option = 'EQ'
low = doccat_ppo )
( fieldname = 'REFDOCNO_I'
sign = 'I'
option = 'EQ'
low = iv_prod_order ) ).
DATA(ls_read_options) = VALUE /scwm/dlv_query_contr_str( data_retrival_only = abap_true
no_lock_errors = abap_true
no_error_if_object_not_found = abap_true ).
/scwm/cl_dlv_management_prd=>get_instance( )->query(
EXPORTING
iv_doccat = iv_doccat
it_selection = lt_selection
is_read_options = ls_read_options
IMPORTING
et_headers = DATA(lt_doc_hdr)
et_items = et_doc_itm
et_items_to = et_doc_itm_wt
eo_message = DATA(lo_message) ).
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
Hi Marius,
in general it is proposed to use APIs like the QUERY to read data instead of accessing the DB directly. The reason is that you are then independent in case DB changes to teh data model are done.
For the QUERY if you use IT_SELECTION you have to pass a "logical fieldname". This is not a fieldname of the DB! A documentation on this and the QUERY can e.g. be found in SE24 if you click on the method documentation of QUERY (this is on the method level, not the class documentation). There is also described how you find the logical fieldnames.
For your example you have to use /SCDL/IF_DL_LOGFNAME_C=>SC_REFDOCNO_PPO_H if you want to select for PPO REFDOCNO on header level or /SCDL/IF_DL_LOGFNAME_C=>SC_REFDOCNO_PPO_I for PPO docno selection on item level.
So e.g.
DATA(lt_selection)=VALUE/scwm/dlv_selection_tab(( fieldname = /SCDL/IF_DL_LOGFNAME_C=>SC_REFDOCNO_PPO_I sign='I'option='EQ'low= iv_prod_order ) ).Best regards
Markus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Markus,
thanks for the fast answer. Yes, I found the related interface where the logical fieldnames are being documented (/SCDL/IF_DL_LOGFNAME_C). I changed the related method according to your answer:
DATA(lt_selection) = VALUE /scwm/dlv_selection_tab( ( fieldname = /scdl/if_dl_logfname_c=>sc_refdocno_ppo_i
sign = 'I'
option = 'EQ'
low = iv_prod_order ) ).
/scwm/cl_dlv_management_prd=>get_instance( )->query(
EXPORTING
it_selection = lt_selection
IMPORTING
et_headers = DATA(lt_doc_hdr)
et_items = et_doc_itm
et_items_to = et_doc_itm_wt
eo_message = DATA(lo_message) ).Unfortunately the method doesn't find the related ref documents if I enter the REFDOCNO 739639 (tried with leading zeros also), e.g.:

Hi Marius,
this is probably a conversion exit issue. Use data element /SCWM/DE_PROD_ORDER if you want to enter a PPO number. This is of type CHAR12 and has a alpha conversion.
According to your database example this is a header reference (as ITEMID is empty). So then use SC_REFDOCNO_PPO_H instead of SC_REFDOCNO_PPO_I. Ensure that you pass the correct number of leading zeros (will be done automatically if you use the above data element for entering data)
Best regards
Markus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 8 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.