
The ALV Grid Control uses the context menu and assigns standard functions to it. Depending on the context, you can add self-defined functions to this menu and hide or disable preset functions.
The context menu is an instance of class CL_CTMENU . If event CONTEXT_MENU_REQUEST is triggered by the user, event parameter E_OBJECT contains a reference to the standard context menu.
See also report BCALV_GRID_06 in development class SLIS .
You can change this menu as follows:
To add an option to the menu, call method add_function :
CALL METHOD E_OBJECT->ADD_FUNCTION
EXPORTING FCODE = 'DELE'
TEXT = TEXT-003. "Delete
To disable existing functions (and gray them out), you pass all corresponding function codes of method disable_functions in a table:
DATA: LT_FCODES TYPE UI_FUNCTIONS,
CLEAR LT_FCODES.
APPEND CL_GUI_ALV_GRID=>MC_FC_COL_OPTIMIZE TO LT_FCODES.
APPEND CL_GUI_ALV_GRID=>MC_FC_HELP TO LT_FCODES.
CALL METHOD E_OBJECT->DISABLE_FUNCTIONS
EXPORTING FCODES = LT_FCODES.
To hide existing functions, you follow the same procedure and call method hide_functions instead of method disable_functions .
With methods enable_functions and show_functions you can enable or display the relevant functions again.
You read the function codes for self-defined functions at event user_command.