Since ECC6 version, it is recommended to use the implementation of the BAdI RSU5_SAPI_BADI instead of the traditional USER EXIT (EXIT_SAPLRSAP_001 to 004).
In this tutorial we will focus on changing transactional data.
Click on
Enter the BAdI's name.
Enter the BAdI's description.
Save
Now, click on the 'Interface' and double-click the name of the class.
For now, the BAdI is created but is not active.
We will look at the first method and writing the dynamic call.
This method of instanciation allows to build the dynamic call of the private methods.
Variable declaration to recovery the Datasrouce's name
DATA : l_method TYPE seocmpname.
The method's name always must begin by a letter, here we had the prefix 'M'
CONCATENATE 'M_' i_datasource INTO l_method.
We verify that the global table contains data.
CHECK c_t_data[] IS NOT INITIAL.
We verify that the called method exists for the class ' ZCL_IM_C_RSU5_SAPI_BADI '.
SELECT SINGLE cmpname FROM seocompo INTO l_method WHERE clsname = 'ZCL_IM_C_RSU5_SAPI_BADI' AND cmpname = l_method.
If the method exists
CHECK sy-subrc EQ 0.
We call the method with the standard parameters.
CALL METHOD (l_method) EXPORTING I_UPDMODE = i_updmode I_T_SELECT = i_t_select I_T_FIELDS = i_t_fields CHANGING C_T_DATA = c_t_data C_T_MESSAGES = c_t_messages.
Now we add our method, the one who will modify the data of our DataSource.
Double-click on the name of the method to focus on the detail.
Start to modify the 'Private Domain' to inform the parameters of the method.
class-methods M_DATASOURCE_NAME importing value(I_UPDMODE) type SBIWA_S_INTERFACE-UPDMODE value(I_T_SELECT) type SBIWA_T_SELECT value(I_T_FIELDS) type SBIWA_T_FIELDS changing !C_T_DATA type ANY TABLE !C_T_MESSAGES type RSU5_T_MESSAGES optional.
For the example, ' datasource_structure ' is the name of the structure generated during the creation of DataSource.
Variable declaration.
FIELD-SYMBOLS: <L_S_DATA> TYPE datasource_structure.
We copy the global table to our internal table.
L_T_DATA[] = C_T_DATA[].
(...) "Your specific selections
Then we curl on the internal table to update the data.
LOOP AT L_T_DATA ASSIGNING <L_S_DATA>. ... ENDLOOP.
Finally we transfer the data in the global table.
C_T_DATA[] = L_T_DATA[].
Do not forget to CLEAR your tables and variables.
Launch the SE19 transaction.
Click on
Click on the activation button
Your BAdI is active.
Astuce pour déboguer un package ...
Vider le cache BPC avec UJA_REFRESH_DIM_CACHE ...