In this article you will learn how to implement a BAdI for table maintenance. You will understand how filters work and get an overview of all methods with respective areas of application.
Our Table Maintenance BAdI blog series in overview
The NextTables BAdI is designed for multiple use and is based on a filter. The business logic inside the respective BAdI implementation is not executed until the filter criteria are met. In the Filter Values section of BAdI implementation you can define criteria to ensure the class is executed for a specific table name and table type only.
If the same filter combination is used in different BAdI implementations, the first one will be executed. Therefore, you must ensure that the filter criteria are always unique.
The enhancement spot /NLY/EDITOR contains a BAdI definition /NLY/BADI_EDITOR, which covers all possible table operations. You can use it to show or hide certain columns, change read/write access and derive fields automatically.
Customer specific logic is deployed in methods of the implementing class. The structure of methods is inherited from the BAdI definition you selected.
BAdI definition /NLY/BADI_EDITOR contains the following methods:
- /NLY/IF_EDITOR~SET_META_EXIT - Exit for Meta (Meta Data of Table)
- /NLY/IF_EDITOR~SET_DATA_EXIT - Exit for Data (Read Access) Before Read
- /NLY/IF_EDITOR~SET_UPDATE_EXIT - Exit for (Write Access) Before Update
I will explain the respective methods in more detail below.
Leveraging the logic inside the META method, you can control properties of the table and respective single fields. Using this method, you can also overwrite the properties set via configuration tables in the front end. The following chart shows which setting will be applied, if it is set in multiple locations.
For example, if a property is neither set in front end nor BAdI, the default setting will be used for display. The default setting can be changed by users in front end and will be used for display if no BAdI is specified. However, if a BAdI configuration is specified, the settings set inside the BAdI overwrite the front end configuration.
You can use the META method to set or change table properties like table name or editability. You can also configure properties of individual fields. For example, you can make certain fields not editable or hide them by changing the visibility. You could also change the search behaviour from dropdown to search or vice versa. Moreover, you can use this method to execute authorization checks on table level. We explain the Meta method in detail in this article.
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.
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. We explain the Data Method in detail in this article.
With the UPDATE method, you can enhance data entered by the user und populate new field. For example, you could use this method to derive the values for Last changed on and Last changed by fields to track changes automatically. We explain the Update method in detail here.
In the following chart you will find an overview of all table maintenance methods.
You can find the detailed explanation of the Update method in this article. The Meta method is described here. The application of both methods to track changes automatically is described here. You can find the detailed explanation of Data method in this article. In every method you can pass messages to the user.