(2105) 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:
Parameter | Type | Description | Optional |
---|---|---|---|
iv_dataprov | Char30 | DataProvider name | |
it_fields | Table | Table with selection fields | |
iv_where | String | WHERE condition (optional) | X |
io_set | cl_rsmds_set | Multi-dimensional Quantity | X |
iv_appending | rs_bool | Append the result to a given table | X |
it_lookup_data | Any table | Lookup data table | X |
it_lookup_cond | Table | Table with lookup conditions | X |
io_log | /DVD/RL_IF_LOG | Interface for log service | X |
ct_data | Any Table | Result data set |
Components of the table it_fields
:
Component | Type |
---|---|
FIELDNAME | CHAR30 |
COMPONENT_INDEX | INT4 |
COMPONENT_NAME | CHAR30 |
SORT_POSITION | INT4 |
AGGREGATION_FUNCTION | CHAR10 |
Components of the table it_lookup_cond
:
Component | Type |
---|---|
FIELDNAME | CHAR30 |
OPTION | CHAR2 |
COMPONENT_NAME | CHAR30 |
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.