Skip to Content
0
Nov 03, 2020 at 12:34 PM

Get delivery document by production order as reference document

1247 Views

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) ).