Using the DATA method, you can customize the select statement to be executed for the given table type and table name. Thus, you can adjust the values shown to the user.
Our Table Maintenance BAdI blog series in overview |
You can use this method to apply additional filter or check selected filters. You can also change field values read from database on the fly according to your business logic, before displaying them to the user. Furthermore, you could also implement your completely own read logic, skipping the standard read logic altogether.
The modification of the filter can be done in I_STEP 1 (before database access) using infos of parameter C_QUERY_POST-SELECT_OPTIONS. In order to implement your own read logic, set E_SKIP parameter to X in I_STEP 1 (before database access). In this case, no standard read logic is executed. Adjustment of field values before they are shown to the user can be done in I_STEP 2 (after database access), utilizing the values in table CO_TABLE.
In both steps, you can pass messages using CT_MESSAGES table. You can find the explanation of I_STEPs below.
The BAdI is triggered, if values are requested from the database. In the I_STEP 1 you can change the selections before the actual READ access to the database is executed. Afterwards, the standard READ command is executed on the database level. You can skip this step by setting the parameter E_SKIP = ‘X’ in I_STEP 1. After the data is requested from the database, you can adjust certain field values or pass messages to the user.
Master-Item filter propagation
In Master Item scenarios, the framework derives additional item filters after the DATA exit I_STEP = 1 based on the parent context (C_QUERY_POST-PARENT_SELECT_OPTIONS) and its mapping information.
Therefore, it is expected that the derived Master Item filter is not yet visible in C_QUERY_POST-SELECT_OPTIONS while debugging inside I_STEP = 1.
In the table below you can find an overview of all parameters and possible values.
|
Property |
Type |
Description |
Possible Values |
|
I_TECHNAME |
CHAR 30 |
Technical name of the table (e.g. /BIC/AZOMACOST2) |
|
|
I_TABNAME |
CHAR 30 |
Table name (e.g. ZOMACOST) |
|
|
I_TTYPE |
CHAR 10 |
Table Type |
DDIC Table of Data Dictionary DSO DSO (Advanced or Classic) CUSTOM Custom (can be used for Views, etc.) IOBJ_ATT InfoObject Attributes IOBJ_TXT InfoObject Texts ALIASTABLE Alias Table |
|
I_TOP |
INT4 |
Number of records to read |
|
|
I_S_TABLE_INFO |
Structure |
Table Info |
Please find detailed explanation here |
|
I_T_FIELDS_INFO |
Structure |
Field Info |
Please fined detailed explanation here |
|
I_STEP |
CHAR 1 |
Step for data read access |
1 Before read access to database 2 After read access to database |
|
E_SKIP |
CHAR 1 |
Skip further processing |
X Skip standard read logic in order to implement your own |
|
CO_TABLE |
Table |
Contains in I_STEP 2 data read from the database |
|
|
C_QUERY_POST |
Structure |
Contains parameters from global filters |
Please refer to the table below |
|
CT_MESSAGES |
Structure |
Contains messages |
You can find detailed explanation in this article |
|
C_TOTAL_ROWS |
INT4 |
Value reflects total number of rows in database according to the selection. NextTables Version 10 and higher. |
Please only change this parameter, if you are implementing a custom table (entity type = custom) or you have implemented your own read access in the data exit (with e_skip = X in i_step = 1). In most cases you do not need to change this value. |
The parameter C_QUERY_POST groups all global query settings that are relevant for the Data Method. This includes selected fields, sorting, global filters and select-options from the NextTables UI. The content of C_QUERY_POST can be evaluated and modified in the Data Exit I_STEP = 1 before it is processed.
|
Field name |
Type |
Kind |
Description / Usage |
|
SELECT |
/NLY/TT_SELECT_FIELDS |
Table type |
List of fields that are requested from the main table. |
|
SORT |
/NLY/TT_SORT_FIELDS |
Table type |
Sort criteria for the result set (field and sort direction). |
|
FILTER |
/NLY/TT_FILTER_FIELDS |
Table type |
Obsolete. Historic additional filter conditions. Use SELECT_OPTIONS instead. |
|
SELECT_OPTIONS |
/NLY/TT_FIELD_SELECT_OPTIONS |
Table type |
Range-based filters per field (similar to ABAP SELECT-OPTIONS). see table below Note (Master Item): The final item select-options can be enriched by the framework after I_STEP = 1. Do not rely on seeing the complete Master Item filter while debugging inside the DATA exit in I_STEP = 1. |
|
FIELDS_TEXT_DISPLAY |
/NLY/TT_SELECT_FIELDS |
Table type |
Fields that are used for text / description display (e.g. for text joins). |
|
PARENT_SELECT_OPTIONS |
/NLY/TT_PARENT_SELECT_OPTIONS |
Table type |
PARENT_SELECT_OPTIONS provides the parent context (level, parent entity) and the field mappings required to translate the parent row context to the item table. It is not a list of final item select-option ranges. The framework uses this structure to derive the item filters later in the processing pipeline. see table below |
The field SELECT_OPTIONS in C_QUERY_POST is a table of type /NLY/TT_FIELD_SELECT_OPTIONS with line structure /NLY/TS_FIELD_SELECT_OPTIONS. It contains all global range-based filters in a form that is compatible with the classic ABAP SELECT-OPTIONS concept.
Read and modify C_QUERY_POST-SELECT_OPTIONS in I_STEP = 1 to inject additional filters or to tighten/relax existing conditions before the standard read logic is executed.
|
Field name |
Data element / Type |
Description / Usage |
|
FIELDNAME |
FIELDNAME (CHAR30) |
Technical field name to which the selection criterion belongs. |
|
SIGN |
CHAR1 |
Include/exclude indicator, e.g. I (include) or E (exclude). |
|
OPTION |
CHAR2 |
Selection option / operator, e.g. EQ, BT, GE, LE, etc. |
|
LOW |
CHAR255 |
Lower boundary or single value of the selection. |
|
HIGH |
CHAR255 |
Upper boundary for interval selections (OPTION = 'BT'), empty for single-value selections. |
The field PARENT_SELECT_OPTIONS in C_QUERY_POST is a table of type /NLY/TT_PARENT_SELECT_OPTIONS with line structure /NLY/TS_PARENT_SELECT_OPTION. It contains select-options that are propagated from a parent (driving) entity to the current table, for example in master-detail scenarios.
Use PARENT_SELECT_OPTIONS when the table is read in a dependent context (e.g. detail table for a selected header). The mapping information can be used to translate parent filters to the child entity.
|
Field name |
Data element / Type |
Description / Usage |
|
LEVEL |
INT8 |
Hierarchy level of the parent context (0 = direct parent, higher = nested). |
|
MAPPINGS |
/NLY/TT_MAPPING |
Mapping table between parent fields and current entity fields. |
|
TABNAME |
/NLY/DE_TABNAME (CHAR30) |
Name of the parent table / entity. |
|
TTYPE |
/NLY/DE_TTYPE (CHAR10) |
Technical type / category of the parent entity. |
How to interpret LEVEL and MAPPINGS (Master Item):
PARENT_SELECT_OPTIONS can contain multiple rows (LEVEL 0…n). Each row represents one parent context level that may contribute to the selection of the current table.
MAPPINGS contains the mapping definitions and the derived select-options that should be applied to the current table based on the selected parent row(s) and the configured Master Item mapping.
Depending on the setup, the relevant mappings may appear on a nested level (LEVEL > 0). This is expected as long as the level that represents the driving master context provides the required mappings.
MAPPINGS is not only “join metadata”. Each row of /NLY/TS_MAPPING already represents a field selection criterion that will be used to restrict the current table (item) based on the selected master context.
|
Field name |
Data element / Type |
Description / Usage |
|
FIELDNAME |
CHAR 30 |
Technical field name on the current (item) entity that the derived selection should be applied to. |
|
LOW |
CHAR 250 |
Derived selection value for FIELDNAME (semantics: lower interval bound; in Master Item cases this is the concrete value coming from the selected master row context to filter the item table). |
You can use the following code snippet as orientation while implementing your own logic.
IF I_STEP = 1.*implement your logic before read access hereELSEIF I_STEP = 2.*implement your logic after read access hereENDIF.
For example, you can use this method to disable planning after the planning round is over. In the example below, the planning round ends in November. Data processing will be skipped using the E_SKIP parameter and an error message will be shown to the user.
IF i_step = 1. IF sy-datum+4(2) = '11'. e_skip = 'X'. ct_messages = VALUE #( BASE ct_messages ( type = /nly/cl_table_rest_v3=>co_msg_type_error visu_type = /nly/cl_table_rest_v3=>co_visu_type_toast hdr = 'Planning not allowed' msg = 'Planning round is over, no values will be displayed') ). ENDIF. ENDIF.
Which License is needed for this feature Professional ✘ | Enterprise ✔