In this article you will learn everything about the SET_UPDATE_EXIT method of the /NLY/BADI_EDITOR BAdI used for table maintenance. You will understand the sequence of validation steps and recieve guidance for your BAdI implementation.
Our Table Maintenance BAdI blog series in overview |
Using the UPDATE method, you can populate new fields and enhance data entered by user. One example could be the derivation of fields Last changed on and Last changed by to track changes automatically.
Your custom logic can be implemented in the BAdI via interface /NLY/IF_BADI_EDITOR using the method /NLY/IF_EDITOR~SET_UPDATE_EXIT.
When data is entered in the table via clipboard, new manual entry or edit of the existing value, different events are triggered. Parameter I_TYPE is filled with the following values, depending on the type of data modification:
They are represented by the following constants:
/nly/cl_table_rest_v3=>co_type_validate - when data is updated, inserted or deleted a validation is triggered.
The default process is triggered every time a new row is created and if one or multiple existing rows are copied. It is processed before the input dialog opens, which means it can not react on any input in the dialog. However it can perform calculations, determine or check data and prefill the fields of the dialog.
Currently there is no difference for the default between the before and after update i_steps.
Validation process is triggered every time when data is updated, inserted or deleted. Depending on the respective step, you can implement your own logic here. For example, in step 1 you could auto-correct or transform certain values. In step 2 you can add additional entries in the validation, such as conditional values for two fields, where both of the fields have to be filled. In this step you could also add or remove standard validation messages.
Regardless of custom validation logic, standard validation is always executed. Standard validations include checks if mandatory fields are filled, checks if key already exist and also checks if values are valid in the InfoObject. In the chart below you can find an overview of respective validation checks.
The ideal time to execute custom validations is after the standard validations were executed. There, you can utilize the following message types which result in different system behaviour:
During custom validation you can also differentiate which kind of operation (insert, update or delete) triggered the validation. You can read the respective value from the I_TYPE_VAL parameter and act accordingly in your custom validation logic.
Each event (validate, insert, update or delete) is executed in two steps: I_STEP 1 and I_STEP 2.
Those are represented by the following constants:
Please be aware, that both steps are executed during the Validate event and then again during Insert/Update/Delete events. Please refer to the following chart for an overview of the event types and steps.
After a user executes an insert, update or delete action the validation process kicks in. In I_STEP 1 (co_step_before_update) you can autocorrect or transform certain values. Afterwards, the standard validation checks are executed. After standard validations you could add additional checks or modify validation messages in I_STEP 2 (co_step_after_update). After the validation process the results are presented to the user, who also has the possibility to accept or decline automatic corrections.
After the validation process, you can execute custom logic before the actual database update. In I_STEP 1 (co_step_before_update) you could enhance data introduced by the user and fill additional fields with a change log. Afterwards, the actual insert, update or delete action is executed and the database is updated. After the actual data base update, in I_STEP 2 (co_step_before_update), you could implement customer logic to start a process chain, which utilizes the updated data. Finally, the user will receive a message of update success or failure.
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_TYPE |
CHAR 10 |
CRUD Type |
update Update insert Insert delete Delete validate Validate default set default value sel_del Selective delection |
I_TYPE_VAL |
CHAR 10 |
CRUD Type for validation (insert,update,delete) |
update Update insert Insert delete Delete validate Validate default set default value sel_del Selective delection |
I_FIELD_VAL |
CHAR 60 |
Field name |
Field name of the field which triggered the validation |
I_S_TABLE_INFO |
Structure |
Table Info |
|
I_T_FIELDS_INFO |
Structure |
Field Info |
|
I_STEP |
CHAR 1 |
Step for update |
1 Before update access to database 2 After update access to database |
I_BUTTON |
CHAR 30 |
Button name |
|
I_S_IMPORT_SETTINGS |
|
|
Please see next table |
E_SKIP |
CHAR 1 |
Skip further processing |
X Skip further processing |
CO_TABLE |
Table |
Contains changed data |
|
CO_TABLE_XXL_FILES |
Table |
|
|
CT_UPDATE_FIELDS_PROPERTIES |
Structure |
Update of field properties |
|
CT_VALIDATION |
Structure |
Contains validation messages |
See below |
CT_SELECT_OPTIONS |
Structure |
Selection criteria field |
|
CT_MESSAGES |
Structure |
Contains messages |
Property |
Type |
Description |
Possible Values |
ROWIDX |
INT4 |
Row number |
|
COLUMN |
CHAR 30 |
Field name |
|
TYPE |
CHAR 30 |
Message type |
WARNING Warning ERROR Error INFO Info SUCCESS Success |
HDR |
STRING |
Message header |
|
MSG |
STRING |
Message |
Property |
Type |
Description |
Possible Values |
FILE_ID |
CHAR 26 |
File ID |
|
FILE_NAME |
CHAR 255 |
File name |
|
FILE_MODE |
CHAR 5 |
file mode: SMALL or LARGE |
|
FILE_TYPE |
CHAR 5 |
ile type: csv or excel |
|
FILE_SIZE |
INT4 |
File size in bytes |
|
HEADER |
CHAR 1 |
First line is a header |
|
THOUSANDSSEPARATOR |
CHAR 1 |
Thousands separator |
|
DECIMALSEPARATOR |
CHAR 1 |
Decimal separator |
|
DELIMITER |
CHAR 1 |
CSV delimiter |
|
DATEFORMAT |
CHAR 10 |
Date format |
ASSIGN co_table->* TO <fs_t_table>.
CASE i_type.
WHEN /nly/cl_table_rest_v3=>co_type_validate
CASE i_step.
WHEN /nly/cl_table_rest_v3=>co_step_before_update.
WHEN /nly/cl_table_rest_v3=>co_step_after_update.
ENDCASE.
WHEN /nly/cl_table_rest_v3=>co_type_update
OR /nly/cl_table_rest_v3=>co_type_insert
OR /nly/cl_table_rest_v3=>co_type_delete.
CASE i_step.
WHEN /nly/cl_table_rest_v3=>co_step_before_update.
WHEN /nly/cl_table_rest_v3=>co_step_after_update.
ENDCASE.
ENDCASE.
Which License is needed for this feature Professional ✘ | Enterprise ✔