Function documentationDefining a Context Menu Locate this document in the navigation structure

 

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.

Integration

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.

Note Note

See also report BCALV_GRID_06 in development class SLIS.

End of the note.

Features

You can change this menu as follows:

  • To add an option to the menu, call method add_function:

    Syntax Syntax

    1. CALL METHOD E_OBJECT->ADD_FUNCTION
      	EXPORTING FCODE = 'DELE'
      	TEXT = TEXT-003. "Delete
    End of the code.

  • To disable existing functions (and gray them out), you pass all corresponding function codes of method disable_functions in a table:

    Syntax Syntax

    1. 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.
    End of the code.
  • 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.

Note Note

You read the function codes for self-defined functions at event user_command.

End of the note.