
Defining a Static Menu
Use
In the SAP GUI for Windowsä Environment, you set up menus in the toolbar dynamically using the events
toolbar, menu_button and context_menu_request. In the SAP GUI for HTML, you are not recommended to follow this procedure for reasons of performance. Instead, you should define all menus of the toolbar as static as described below (context menus are generally not supported). You define these menus at the event toolbar before the ALV Grid Control is displayed.Process Flow
data: ls_toolbar TYPE stb_button,
ls_menu TYPE stb_btnmnu,
lc_menu TYPE REF TO cl_ctmenu.
CLEAR ls_toolbar.
ls_toolbar-function = 'STATIC_MENU1'.
ls_toolbar-icon = icon_led_interactive.
ls_toolbar-butn_type = '2'.
ls_toolbar-text = 'first static menu'.

You use the field
butn_type to communicate the type of the GUI element to the ALV Grid Control. For menus with a default button, you use type ' 1 '.APPEND ls_toolbar TO e_object->mt_toolbar.
create object lc_menu.
call method lc_menu->add_function
exporting fcode = 'STATIC_MENU1_FUNC1'
text = 'first menu entry'.
ls_menu-ctmenu = lc_menu.
ls_menu-function = 'STATIC_MENU1'.
append ls_menu to e_object->mt_btnmnu.
call method cl_gui_control=>set_focus
exporting control = sender.
Result
You can retrieve the function code that you have defined in the field
function in the event handler method for the event USER_COMMAND to implement the associated function.