Tuesday, June 29, 2010



Context menus (right mouse key, SHIFT F10) are shortcuts for functions that are frequently used.

They can be used to display context-sensitive menus. The context is defined by the position (cursor for SHIFT F10, mouse location for right mouse key) where the user called the context menu. If needed, you can specify the context more precisely with the displayed contents. This permits the user to select functions that are relevant for the current context using the context menu.

You define whether a context menu should be offered when you create a screen object (screens, input fields, table controls, boxes, ...). When the user selects a context menu on an object, an event mechanism (as understood by ABAP objects) calls a certain subroutine in the application program.

The program is assigned a menu reference. The program uses this menu reference to build the display menu. Menus defined with the Menu Painter and dynamic menus can be used here.

After the user executes a menu function, the application program regains control and can react to the user input.

Context menus are assigned to output fields. When you assign a context menu to a box, table control or screen (normal or subscreen), all the subordinate output fields that do not have a context menu inherit that one.

You can create a context menu from within the object list of the Object Navigator. Position the cursor on GUI status and right-click. The Object Navigator automatically opens the Menu Painter.

Of course you can also create a context menu directly in the Menu Painter.

A context menu is a special GUI status. Assign it a name, a descriptive text and status type Context menu.

In a context menu you can link any function codes and function texts. In particular, you can take advantage of your screen pushbuttons. The functions already provided in the interface can be used as an F4 input help.

The link technique ensures consistent context menus in large applications.

You should observe the following rules when designing context menus.

Do not use any functions that cannot be found elsewhere in the system (pushbuttons or interface).

Avoid using more than two hierarchy levels in context menus.

Do not use more than 10 entries, but map all the available pushbuttons.

Use separators to structure the context menu optically.

Place object-specific statements at the beginning of the menu.

Pressing the right mouse key triggers a callback routine in your program. You can create this callback routine in your application program with forward navigation. It is named ON_CTMENU_. You define which callback routine is called in the Screen Painter.

You can directly assign a callback routine to input/output fields, text fields and status icons. Checkboxes, radio buttons and pushbuttons do not have their own callback routines. However, these fields can inherit context menus from boxes or screens.

If you assign a callback routine to a table control, it is triggered for all the fields of the table control that do not have their own callback routine.

The callback routine has the following form:

The context menu is built with a method call for the instance of class cl_ctmenu that was passed.

Clicking with the right mouse key on an output field triggers the corresponding callback routine.

You can now use the static method load_gui_status of class cl_ctmenu to load a context menu that was predefined in the Menu Painter. Using other methods of class cl_ctmenu (see next slide) you can also completely rebuild the context menu or modify a loaded menu.

If the user triggers a function in the context menu, the corresponding function code is placed in the command field and triggered depending on function type PAI of the screen.

The class cl_ctmenu provides a number of other methods in addition to the static method load_gui_status. You can use them to adjust the context menu at runtime (e.g. using the values in data fields).

The corresponding methods are called within the callback routine.

You can find further information in the documentation for class cl_ctmenu in the Class Builder.

No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)


Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive