Offering the Context Menu 

Use

Instead of a toolbox in a separate window, you can insert the service in a context menu that can be displayed by positioning the cursor on the object and right mouse-clicking.

Procedure

  1. When generating an instance of cl_gos_manager you do not transfer an object identifier (or callback class). No object is published:
  2. data: go_myobject type ref to cl_gos_manager.

    create object go_myobject.

  3. You do not transfer the object until you request the context menu:
  4. data: ...,

    lo_menu type ref to cl_ctmenu,

    ls_object type borident.

    call method go_myobject->get_context_menu

    exporting is_object = ls_object

    importing eo_menu = lo_menu.

    The import parameter lo_menu contains a reference to the context menu.

  5. You can append the context menu to various controls. Normally you must write an event handler which forwards the menu entries selected by the user. In the event handler call a method from cl_gos_manager for generic object services:

call method go_myobject->dispatch_menu_command

importing ip_fcode = lp_fcode

io_menu = lo_menu.

You only have to request lo_menu here if you have requested more than one context menu within the same instance from cl_gos_manager.