With NextTables Version 9.0, you can use a BAdI to add a user-defined button to the quick, top or context menu. You can use this button to add custom functions in the back or front end. For example, user can execute a process chain at the push of a button or check its status. In addition, the user can differentiate whether all data or only the selected rows should be considered. After execution, messages can also be displayed to the user.
Custom buttons can be created using the META Method of the Table Maintenance BAdI. In the article “How to implement a BAdI for NextTables” you will learn how to create a BAdI.
Following parameters must be defined: NAME, DESCR, ACTION and LOCATION. NAME represents the ID of the respective button, which can be used to differentiate the button pressed by the user and in defining submenus. DESCR represents the description of the button shown to the user.
ACTION parameter defines the action to be executed after the buttons was pressed. It can contain following values:
LOCATION parameter defines whether the button appears in the top or context menu. It can contain following values:
Furthermore, child entries in submenus contain parameters SORT_ORDER and PARENT. PARENT defines the top node of the menu, while SORT_ORDER influences the sequence of the entries. SORT_ORDER can be any numerical value.
Icons can be added to buttons with the parameter ICON. Simply choose an icon from Font Awesome. The supported style is "regular". Example would be ICON = 'paper-plane'.
A tooltip can be added to the button with the parameter TOOLTIP. If a tooltip is added, the description becomes optional. This combination allows to place buttons with only an icon displayed in the top location. If the button is placed into the quick action menu, the tooltip will be shown instead of the description.
Custom Button create a variety of options. You can read the value sent in the Update Exit and manipulate them based on a custom logic. There are no limits to the imagination. For example, you can implement a process that does something specific to selected rows like setting a status.
Furthermore, using the BUTTON action, you can evaluate the button name using the I_BUTTON parameter and execute another functionality for each button. For instance, you can start one process chain with the first button and another with the second. Using the third button, you can check the status of the first process chain and send a message to the user. Below you can find a code snippet as an example for process chain execution.
METHOD /nly/if_editor~set_update_exit.
IF i_button IS NOT INITIAL.
CASE i_button.
WHEN 'BUTTON_URL_T_1' .
CALL FUNCTION 'RSPC_CHAIN_START'
EXPORTING
i_chain = 'ZDRS_PC_ZDREXMPL1'.
WHEN 'BUTTON_URL_T_2' .
CALL FUNCTION 'RSPC_CHAIN_START'
EXPORTING
i_chain = 'ZDRS_PC_ZDREXMPL2'.
ENDCASE.
ENDIF.
ENDMETHOD.
You can also create submenus to group multiple custom buttons. Please note, that the parent node’s ACTION parameter must have NO_ACTION as value. Please refer to the code snippet below as an example.
METHOD /nly/if_editor~set_meta_exit.
ch_s_table_info-buttons = VALUE #( BASE ch_s_table_info-buttons
"TOP MENU ENTRIES
( name = 'NO_ACTION_T' descr = 'Start Process Chain' action = /nly/cl_table_rest_v3=>co_action_no_action location = /nly/cl_table_rest_v3=>co_location_top )
"TOP MENU CHILD ENTRIES
( name = 'BUTTON_URL_T_1' descr = 'Process Chain 1' action = /nly/cl_table_rest_v3=>co_action_button location = /nly/cl_table_rest_v3=>co_location_top sort_order = '0' parent = 'NO_ACTION_T' )
( name = 'BUTTON_URL_T_2' descr = 'Process Chain 2' action = /nly/cl_table_rest_v3=>co_action_button location = /nly/cl_table_rest_v3=>co_location_top sort_order = '1' parent = 'NO_ACTION_T' )
).
ENDMETHOD.
Submenus for the context menu work in the same way.
METHOD /nly/if_editor~set_meta_exit.
ch_s_table_info-buttons = VALUE #( BASE ch_s_table_info-buttons
"CONTEXT MENU ENTRIES
( name = 'NO_ACTION_C' descr = 'Start Process Chain' action = /nly/cl_table_rest_v3=>co_action_no_action location = /nly/cl_table_rest_v3=>co_location_context )
"CONTEXT MENU CHILD ENTRIES
( name = 'BUTTON_URL_C_1' descr = 'Process Chain 1' action = /nly/cl_table_rest_v3=>co_action_button location = /nly/cl_table_rest_v3=>co_location_context sort_order = '0' parent = 'NO_ACTION_C' )
( name = 'BUTTON_URL_C_2' descr = 'Process Chain 2' action = /nly/cl_table_rest_v3=>co_action_button location = /nly/cl_table_rest_v3=>co_location_context sort_order = '1' parent = 'NO_ACTION_C' )
).
ENDMETHOD.
You can also localize your buttons and display a different description, based on the logon language selected by the user. Please refer to the code snippet below for orientation. If the user selected English as language, English description is shown. Otherwise the description is shown in German.
METHOD /nly/if_editor~set_meta_exit.
DATA: lv_send_all TYPE string.
IF sy-langu = 'E'.
lv_send_all = 'Send all data'.
ELSE.
lv_send_all = 'Alle Daten senden'.
ENDIF.
ch_s_table_info-buttons = VALUE #(
"TOP MENU ENTRIES
( name = 'SEND_ALL_T' descr = lv_send_all action = /nly/cl_table_rest_v3=>co_action_send_all location = /nly/cl_table_rest_v3=>co_location_top )
).
ENDMETHOD.
Below you can use a code snippet contained all buttons, which you can use as reference for you own BAdIs.
METHOD /nly/if_editor~set_meta_exit.
ch_s_table_info-buttons = VALUE #( BASE ch_s_table_info-buttons
"TOP MENU ENTRIES
( name = 'SEND_ALL_T' descr = 'Send all' action = /nly/cl_table_rest_v3=>co_action_send_all location = /nly/cl_table_rest_v3=>co_location_top )
( name = 'SEND_SEL_T' descr = 'Send selected' action = /nly/cl_table_rest_v3=>co_action_send_sel location = /nly/cl_table_rest_v3=>co_location_top )
( name = 'BUTTON_T' descr = 'Custom Function' action = /nly/cl_table_rest_v3=>co_action_button location = /nly/cl_table_rest_v3=>co_location_top )
( name = 'NO_ACTION_T' descr = 'Start Process Chain' action = /nly/cl_table_rest_v3=>co_action_no_action location = /nly/cl_table_rest_v3=>co_location_top )
"TOP MENU CHILD ENTRIES
( name = 'BUTTON_URL_T_1' descr = 'Process Chain 1' action = /nly/cl_table_rest_v3=>co_action_button location = /nly/cl_table_rest_v3=>co_location_top sort_order = '0' parent = 'NO_ACTION_T' )
( name = 'BUTTON_URL_T_2' descr = 'Process Chain 2' action = /nly/cl_table_rest_v3=>co_action_button location = /nly/cl_table_rest_v3=>co_location_top sort_order = '1' parent = 'NO_ACTION_T' )
"CONTEXT MENU ENTRIES
( name = 'SEND_ALL_C' descr = 'Send all' action = /nly/cl_table_rest_v3=>co_action_send_all location = /nly/cl_table_rest_v3=>co_location_context )
( name = 'SEND_SEL_C' descr = 'Send selected' action = /nly/cl_table_rest_v3=>co_action_send_sel location = /nly/cl_table_rest_v3=>co_location_context )
( name = 'BUTTON_C' descr = 'Custom Function' action = /nly/cl_table_rest_v3=>co_action_button location = /nly/cl_table_rest_v3=>co_location_context )
( name = 'NO_ACTION_C' descr = 'Start Process Chain' action = /nly/cl_table_rest_v3=>co_action_no_action location = /nly/cl_table_rest_v3=>co_location_context )
"CONTEXT MENU CHILD ENTRIES
( name = 'BUTTON_URL_C_1' descr = 'Process Chain 1' action = /nly/cl_table_rest_v3=>co_action_button location = /nly/cl_table_rest_v3=>co_location_context sort_order = '0' parent = 'NO_ACTION_C' )
( name = 'BUTTON_URL_C_2' descr = 'Process Chain 2' action = /nly/cl_table_rest_v3=>co_action_button location = /nly/cl_table_rest_v3=>co_location_context sort_order = '1' parent = 'NO_ACTION_C' )
).
ENDMETHOD.
Which License is needed for this feature Professional ✘ | Enterprise ✔