Table Maintenance - Data Method Explained

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

  1. Table Maintenance - How to Implement a BAdI (general overview)
  2. Table Maintenance BAdI - Meta Method Explained
  3. Table Maintenance BAdI - Data Method Explained
  4. Table Maintenance BAdI - Update Method Explained
  5. Table Maintenance BAdI - Error Handling Explained

Data shown your way

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.

I_STEP explained

I_STEP overview data method

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.

Overview of all parameters

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

CHANGELOG    Change Log (Advanced DSO)

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 next table

CT_MESSAGES

Structure

Contains messages

You can find detailed explanation in this article

 

Code Snippet

You can use the following code snippet as orientation while implementing your own logic.

IF I_STEP = 1.
*implement your logic before read access here
ELSEIF I_STEP = 2.
*implement your logic after read access here
ENDIF.
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.

Planning not allowed

NextTables BAdI Reference