Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

HI...............

Former Member
0 Likes
897

How can we create a menu painter? What is context menu? How can we create a context menu?

Thanks....

1 ACCEPTED SOLUTION
Read only

Former Member

How can we create a menu painter? What is context menu? How can we create a context menu?

Thanks....

6 REPLIES 6
Read only

Former Member
0 Likes
856

Hi,

Context Menus

The user interface of a screen is defined by a GUI status, which you define in the Menu Painter and assign the type Dialog status. For each dialog status, the system

automatically creates a standard context menu, which the user can display by clicking the righthand mouse button on the screen (or choosing Shift+F10). The standard context menu contains all of the function keys to which functions are assigned. It therefore makes it easy to access any function code that is available using the keyboard, since normally only the most important are assigned to the application toolbar.

However, as well as the standard context menu, you can define context-specific menus for any of the following screen elements:

Input/output fields

Text fields

Table controls

Group boxes

Subscreens

When you select one of these elements using the right-hand mouse button, you can create a dynamic context menu in the ABAP program. This may contain any functions, and is not

restricted to function keys. You cannot assign context menus to pushbuttons, checkboxes, or radio buttons. However, you can assign unique function codes to them instead.

Example

The following example shows some of the technical possibilities for creating context menus, but

does not necessarily observe all of the style guidelines.

REPORT demo_dynpro_context_menu.

DATA: field1 TYPE i VALUE 10,

field2 TYPE p DECIMALS 4.

DATA: prog TYPE sy-repid,

flag(1) TYPE c VALUE 'X'.

DATA: ok_code TYPE sy-ucomm,

save_ok TYPE sy-ucomm.

prog = sy-repid.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.

SET TITLEBAR 'TIT100'.

IF flag = 'X'.

SET PF-STATUS 'SCREEN_100' EXCLUDING 'REVEAL'.

ELSEIF flag = ' '.

SET PF-STATUS 'SCREEN_100' EXCLUDING 'HIDE'.

ENDIF.

LOOP AT SCREEN.

IF screen-group1 = 'MOD'.

IF flag = 'X'.

screen-active = '1'.

ELSEIF flag = ' '.

screen-active = '0'.

ENDIF.

MODIFY SCREEN.

ELSEIF screen-name = 'TEXT_IN_FRAME'.

IF flag = 'X'.

screen-active = '0'.

ELSEIF flag = ' '.

screen-active = '1'.

ENDIF.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDMODULE.

MODULE cancel INPUT.

LEAVE PROGRAM.

ENDMODULE.

MODULE user_command_0100.

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'HIDE'.

flag = ' '.

WHEN 'REVEAL'.

flag = 'X'.

WHEN 'SQUARE'.

field2 = field1 ** 2.

WHEN 'CUBE'.

field2 = field1 ** 3.

WHEN 'SQUAREROOT'.

field2 = field1 ** ( 1 / 2 ).

WHEN 'CUBICROOT'.

field2 = field1 ** ( 1 / 3 ).

ENDCASE.

ENDMODULE.

*******************************************************

Callback-Routines

*******************************************************

FORM on_ctmenu_text USING l_menu TYPE REF TO cl_ctmenu.

CALL METHOD:l_menu->load_gui_status

EXPORTING program = prog

status = 'CONTEXT_MENU_1'

menu = l_menu.

ENDFORM.

FORM on_ctmenu_frame USING l_menu TYPE REF TO cl_ctmenu.

CALL METHOD:l_menu->load_gui_status

EXPORTING program = prog

status = 'CONTEXT_MENU_2'

menu = l_menu,

l_menu->load_gui_status

EXPORTING program = prog

status = 'CONTEXT_MENU_1'

menu = l_menu,

l_menu->set_default_function

EXPORTING fcode = 'HIDE'.

ENDFORM.

FORM on_ctmenu_reveal USING l_menu TYPE REF TO cl_ctmenu.

CALL METHOD:l_menu->load_gui_status

EXPORTING program = prog

status = 'CONTEXT_MENU_3'

menu = l_menu,

l_menu->load_gui_status

EXPORTING program = prog

status = 'CONTEXT_MENU_1'

menu = l_menu,

l_menu->set_default_function

EXPORTING fcode = 'REVEAL'.

ENDFORM.

FORM on_ctmenu_input USING l_menu TYPE REF TO cl_ctmenu.

DATA calculate_menu TYPE REF TO cl_ctmenu.

CREATE OBJECT calculate_menu.

CALL METHOD: calculate_menu->add_function

EXPORTING fcode = 'SQUARE'

text = text-001,

calculate_menu->add_function

EXPORTING fcode = 'CUBE'

text = text-002,

calculate_menu->add_function

EXPORTING fcode = 'SQUAREROOT'

text = text-003,

calculate_menu->add_function

EXPORTING fcode = 'CUBICROOT'

text = text-004,

l_menu->add_submenu

EXPORTING menu = calculate_menu

text = text-005.

ENDFORM.

Regards,

Read only

Former Member
0 Likes
856

Hi,

Using SM41 we can create menu painter.

in this we can keep our own menu options in the menu bar..

context menu : go to se80.

give your package name.press ente.

you will get all objects created under that package.

right click on any one object you will get some options that is called context menu.

I think we can't create context menu.

just we will use the already existing context menus.

regards,

swami.

Read only

Former Member
Read only

Former Member
0 Likes
856

Creating a Context Menu

Use

You can use the entries from a context menu that you define in the Menu Painter to construct a context menu on a screen or list using the method LOAD_GUI_STATUS from the global class CL_CTMENU.

Procedure

To create a context menu from the Object Navigator:

Select Program objects and choose Edit.

Enter the name of the ABAP program.

Choose GUI Status and enter the name of your context menu.

This is the name that you will pass to the importing parameter STATUS of the method LOAD_GUI_STATUS.

Choose Create.

The Create Status dialog box appears, containing fields for the status attributes.

Enter a short text.

Select the status type context menu.

Choose Continue.

The work area for the context menu appears.

In the Code column, enter a function code, and under Text, the corresponding text for the menu entry.

Repeat step 8 for each further function you want to add to your context menu.

If you want to enter a separator, choose Edit ® Insert ® Separator.

If you want to create a cascading menu, leave the Code field empty, and enter the menu text for the cascading menu. You can then open it by double-clicking, and enter the required entries.

Example:

Result

You have created a set of functions that can be used as a template for constructing a context menu.

For information about how to define the relevant processing logic in ABAP, refer to Context Menus.

Read only

0 Likes
856

Could you please be more specific about using the method LOAD_GUI_STATUS from the global class CL_CTMENU.?

Read only

Former Member
0 Likes
856

Hi Jhansi,

go to se41,

The Menu Painter Interface

From the initial screen of the Menu Painter, you choose a status of a program, and then the work area is displayed. Here, you can edit all of the components of the screen.

From the worksheet, you can create a menu bar, define menu functions, assign F keys, customize the standard tool bar, and create an application toolbar.

To maintain the menu bar, application toolbar, or function key settings, click the Expand icon next to the relevant area.

Interface Object List

The Menu Painter keeps lists of all components of the GUI. These are used for component administration, and have functions such as Create, Rename, Copy, and so on. For example, the menu list contains the entries from all of the menu bars in the program. In all, there are six different lists (status list, menu list, function list, title list, menu bar list and function key setting list). You can access any of these lists from the Goto menu of the worksheet, or from the initial screen of the Menu Painter. Regardless of where you make changes, on the worksheet or through a list view, the Menu Painter updates and saves your changes in the same manner. You can also change menu texts, function texts, icons, title texts and short documentation if you access the list in change mode. The lists not only give a rapid overview of the interface components for the whole program, they also make it easier to maintain their text entries.

Saving Your Work

While you are within the Menu Painter, you do not have to save your work each time you move from the Worksheet view to a display list view. In principle, you only need to save your work before you leave the Menu Painter altogether. You do this using the Save function. However, if you do forget to save, the system will remind you by displaying a dialog box before you leave the Menu Painter.

Activating the Interface

None of the changes you make to your interface are visible at runtime until you activate it. Once you have completed and tested your changes, you must reactivate the interface. When you activate the interface, the system creates a load version of it. After activation, your last set of changes becomes visible in all programs that use the interface.

For Context Menus.

http://help.sap.com/saphelp_47x200/helpdata/en/9f/db961235c111d1829f0000e829fbfe/frameset.htm

Regards.

Eshwar.