/
(2205) Lookup API documentation

(2205) Lookup API documentation

Advanced users may use the class /DVD/OFF_CL_DATAPROV_QUERY to create their own reports to retrieve data. Below you can find API documentation of the SELECT method of this class.

CALL METHOD /dvd/off_cl_dataprov_query=>select
  EXPORTING
    iv_dataprov = lv_datapov_name
    it_fields   = it_fields
    iv_where    = `CALYEAR BETWEEN '1991' AND '2016' AND /DV1/S_DMTEMP = '1529.000'`
  CHANGING
    ct_data     = ct_data.

Parameters of above SELECT method:

ParameterTypeDescriptionOptional
iv_dataprovChar30DataProvider name
it_fieldsTableTable with selection fields

iv_whereStringWHERE condition (optional)X
io_setcl_rsmds_setMulti-dimensional QuantityX
iv_appendingrs_boolAppend the result to a given tableX
it_lookup_dataAny tableLookup data tableX
it_lookup_condTableTable with lookup conditionsX
io_log/DVD/RL_IF_LOGInterface for log serviceX
ct_dataAny TableResult data set

Components of the table it_fields:

ComponentType
FIELDNAMECHAR30
COMPONENT_INDEXINT4
COMPONENT_NAMECHAR30
SORT_POSITIONINT4
AGGREGATION_FUNCTIONCHAR10

Components of the table it_lookup_cond:

ComponentType
FIELDNAMECHAR30
OPTIONCHAR2
COMPONENT_NAMECHAR30

Examples

Example of where condition

CALYEAR <= '2014' OR CALYEAR >= '2017'

/DV1/S_DMJPARK = 'HALF DOME'

/DV1/S_DMMANAGER BETWEEN 'BENEDICT SHAFFER' AND 'JULIAN MCKEE'

REQUEST IN ('DTPR_A81S6DLQ2HEYCGB3MLMO84FRG','DTPR_CTMJQQVZ65AA3NW5VQOCFZ7PO')

CDATE = '20050101'

How to obtain fields of a DDIC table

Use the Function Module DDIF_FIELDINFO_GET to obtain fields of DDIC table, which are used as an importing parameter for the table it_fields.

CALL FUNCTION 'DDIF_FIELDINFO_GET'
  EXPORTING
    TABNAME              = lv_ddic_tabname
*   FIELDNAME            = ' '
*   LANGU                = SY-LANGU
*   LFIELDNAME           = ' '
*   ALL_TYPES            = ' '
*   GROUP_NAMES          = ' '
*   UCLEN                =
*   DO_NOT_WRITE         = ' '
* IMPORTING
*   X030L_WA             =
*   DDOBJTYPE            =
*   DFIES_WA             =
*   LINES_DESCR          =
* TABLES
*   DFIES_TAB            =
*   FIXED_VALUES         =
* EXCEPTIONS
*   NOT_FOUND            = 1
*   INTERNAL_ERROR       = 2
*   OTHERS               = 3
          .

Code example using the SELECT method

This is an example of the SELECT method used in a report. The below code contains hardcoded values that should be replaced with values relevant to the system where the code is executed.

DATA:
  lref_data TYPE REF TO data,
  lx_error TYPE REF TO cx_root,
  lt_sm_fields TYPE /DVD/SM_T_FIELD_DEF,
  lt_fields TYPE /dvd/off_query_t_field_sel,
  ls_fields TYPE /dvd/off_query_s_field_sel,
  ls_sm_field  TYPE /dvd/sm_s_field_def,
  lv_count  TYPE int4.

FIELD-SYMBOLS:
  <lt_data> TYPE ANY TABLE.

TRY .
  CREATE DATA lref_data TYPE TABLE OF ('/BIC/AZJG_AD012').
  ASSIGN lref_data->to <lt_data>.

  /dvd/sm_cl_tab_storman=>get_ddic_fields(
    EXPORTING
      iv_tabname '/BIC/AZJG_AD012'
    IMPORTING
      et_field   lt_sm_fields
  ).

  LOOP AT lt_sm_fields INTO ls_sm_field.
    "Move fields
    ls_fields-fieldname  ls_sm_field-fieldname.
    APPEND ls_fields TO lt_fields.

  ENDLOOP.

  CALL METHOD /dvd/off_cl_dataprov_query=>select
    EXPORTING
      iv_dataprov 'ZJG_AD01'
      it_fields   lt_fields
      iv_where    `CALYEAR <= '2005'`
    CHANGING
      ct_data     <lt_data>.

  lv_count lines<lt_data> ).
  WRITE'Lines of data read: 'lv_count.
  EXIT.

CATCH cx_root INTO lx_error.

ENDTRY.

Related content

(2208) Lookup API documentation
(2208) Lookup API documentation
More like this
(2111) Lookup API documentation
(2111) Lookup API documentation
More like this
(2211) Lookup API documentation
(2211) Lookup API documentation
More like this
(2302) Lookup API documentation
(2302) Lookup API documentation
More like this
(1905) Lookup API documentation
(1905) Lookup API documentation
More like this
(1811) Lookup API documentation
(1811) Lookup API documentation
More like this