Show TOC

Using GUI StatusesLocate this document in the navigation structure

Use

A GUI status is a standalone component of an ABAP program. GUI statuses are created and edited in Menu Painter in ABAP Workbench. There are three different types of GUI status:

  • Dialog status

  • Dialog box

  • Context menus

The relevant documentation provides comprehensive information about creating GUI statuses and their elements. The most important properties are summarized below.

GUI Status

The function of a GUI status is to provide the user with a range of functions on a dynpro Each function has an associated function code of up to 20 characters, and when the user chooses a function, the PAI event is triggered. In each PAI event, the function code, as long as it is not empty, is passed to the system field syst-ucomm (sy-ucomm) and assigned to the OK_CODE field. Empty function codes are not passed to the sy-ucomm field or to the OK_CODE field. Before the OK_CODE field can be used, it must be given a name (and hence declared) in Screen Painter. For more information, see Evaluating Function Codes.

All function codes in an ABAP program, apart from those only assigned to pushbuttons on dynpros, are defined and administered in Menu Painter.

The GUI status type defines how the function codes are displayed:

  • A dialog status comprises a menu bar, a toolbar, an application toolbar, and the function key settings.

  • A status for a dialog box only contains a toolbar. The standard function codes of the toolbar and function codes that are associated with function keys but not with the application toolbar are available using the keyboard.

  • A context menu consists solely of a context menu and is used as the static model for the dynamic creation of context menus.

Dialog statuses are the most general form of user interface for dynpros and the following handles these statuses only. With the above restrictions, the same applies to statuses for dialog boxes as applies to dialog statuses. Both are mostly created statically for ABAP programs. Context menus have a somewhat different role and are handled in a special way.

Dialog Status

A dialog status consists of a menu bar, a standard toolbar, an application toolbar, and a function key setting. When a dialog status is defined in Menu Painter, every function code is assigned to a menu entry in a menu bar and/or to a freely assignable function key on the keyboard. Function codes that are assigned to a function key can also be assigned to an icon in the standard toolbar or a pushbutton in the application toolbar. For each function code, there is a static or dynamic function text. Dynamic function texts allow context-sensitive texts to be used in ABAP programs.

The user interface is a visualization of all possible functions, and makes applications programs easier to use. From a technical point of view, it is enough to just enter the function code in the command field and trigger the PAI event by pressing ENTER. However, a dialog status should contain all possible function codes as menu entries. The most important functions should also be assigned to function keys, and the most important of these should also be assigned to icons in the standard toolbar or the application toolbar.

In Menu Painter, the functions assigned to the icons in the standard toolbar must also be assigned to specific function keys. These keys cannot be chosen. Instead, the system automatically assigns them to the corresponding function key when the function code is assigned to an icon. At least one of the icons F3, Shift+F3, or F12 should be activated, so that the user can always leave the screen in a regular fashion. The assignment of function keys to pushbuttons in the application toolbar is not fixed.

Function codes should be assigned to interface elements in accordance with the ergonomic guidelines in the SAP Style Guide . Menu Painter offers help in this respect by providing the Display Standards function and its corresponding checks.

As well as the function codes for Normal Application Functions, which trigger the PAI event, function codes can also be created in Menu Painter with other functions, for example, to call another transaction or trigger a system function. Function codes like this can also be assigned to pushbuttons, checkboxes, or radio buttons on dynpros. To enable this, however, a different function type must be assigned to the function code in either Menu Painter or Screen Painter.

Area Menus

Menu Painter can also be used to create area menus. An area menu is a user interface that is not part of an ABAP program and hence cannot trigger any PAI events. It can only contain function codes that call transactions or system functions. Examples of area menus are the initial screen of the SAP system (S000) and the initial screen of ABAP Workbench (S001).

Special Function Keys and Function Codes

Some keys and function codes have special functions. This section deals with the special functions on dynpros. There are also special functions that apply to dialog statuses for lists.

Reserved Function Keys

The following function keys do not trigger the PAI event, but are reserved for other functions:

  • F1 calls the field help.

  • F4 calls the input help.

  • F10 places the cursor in the menu bar.

Function Keys for the Standard Toolbar

The following function keys have fixed assignments to icons in the standard toolbar. The function code assigned and the corresponding ABAP code in the program should reflect the sense of the icon.

Function Key

Icon

Purpose

Ctrl+S or F11

Save

F3

Back

Shift+F3

Exit

Esc or F12

Cancel

Ctrl+P

Print

Ctrl+F

Find

Ctrl+G

Find Next

Ctrl+PgUp

First Page

PgUp

Previous Page

PgDn

Next Page

Ctrl+PgDn

Last Page

The ENTER Key

The ENTER key is associated with the icon in the standard toolbar, and is always active, even if no function is assigned to it in the GUI status, or if there is no GUI status set at all. The PAI event is always triggered when the user chooses ENTER. The following function codes can be passed to sy-ucomm or the OK_CODE field:

  • When an entry is made in the command field on the toolbar, it is passed to sy-ucomm and the OK_CODE field a function code.

  • If no entry is made in the command field and a function code is assigned to the ENTER key in Menu Painter, this function code is passed to sy-ucomm and the OK_CODE field.

  • If the command field does not contain an entry and no function code is assigned to the ENTER key in Menu Painter, the function code is empty and therefore not passed to sy-ucomm or the OK_CODE field.

The F2 Key

The F2 key is always associated with a mouse double-click. If a function code in the GUI status is assigned to the F2 key, the PAI event can be triggered either when F2 is chosen or when a screen element is double-clicked. In both cases, the associated function code is passed to sy-ucomm and the OK_CODE field. If the associated cursor position in the ABAP program also needs to be used, this must be determined using GET CURSOR.

Setting a Dialog Status

Dialog statuses are assigned to dynpros using the following ABAP statement:

SET PF-STATUS stat [OF PROGRAM prog]
                   [EXCLUDING f|itab].
            

This statement defines the user interface for all subsequent dynpros in a dynpro sequence until another dialog status is set using a new SET PF-STATUS statement. The dialog status stat must be a component of the current ABAP program, unless the addition OF PROGRAM is used to set a dialog status of another program prog.

The addition EXCLUDING can be used to modify the appearance and function of a dialog status dynamically. This is useful if the individual user interfaces for a range of dynpros are very similar. A single global status can be defined and those functions not needed deactivated using EXCLUDING. f can be specified to deactivate the function code stored in field f. itab can be specified to deactivate all function codes stored in the internal table itab. The field f and the rows of table itab should have the type c with the length 20.

The dialog status for a dynpro should be set at PBO time. If a dialog status is not specified for a dynpro, it is displayed with the user interface of the previous dynpro. If a dialog status is not specified for the first dynpro of a program, it does not have a user interface, and the user may not be exit to leave the dynpro.

Setting a GUI Title

As well as the dialog status, a user interface also contains a GUI title, also created using Menu Painter. GUI titles are assigned to dynpros using the following ABAP statement:

SET TITLEBAR tit [OF PROGRAM prog]
                 [WITH g1 ... g9].
            

This statement defines the title of the user interface for all subsequent dynpros in a dynpro sequence until another GUI title is set using a new SET TITLEBAR statement. The GUI title title must be a component of the current ABAP program, unless the addition OF PROGRAM is used to set a GUI status of another program prog.

A GUI title can contain up to nine different placeholders &1 ... &9. They can be replaced by the addition option WITH with the contents of the corresponding fields g1 ... g9. Any individual '&' placeholders are also replaced in order by the content of the corresponding g parameter. The '&' character is displayed by repeating it in the title: '&&'.

The GUI title for a dynpro should be set at PBO time.

Dialog Status and Dynpro



PROGRAM demo_dynpro_gui_status.
DATA: ok_code TYPE sy-ucomm,
      save_ok LIKE ok_code,
      output  LIKE ok_code.
CALL SCREEN 100.
MODULE init_screen_0100 OUTPUT.
  SET PF-STATUS 'STATUS_100'.
  SET TITLEBAR '100'.
ENDMODULE.
MODULE user_command_0100 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
      LEAVE PROGRAM.
    WHEN OTHERS.
      output = save_ok.
  ENDCASE.
ENDMODULE.




            

The static next dynpro number of dynpro 100 is 100. It has the following layout:

The part of the element list relevant for the dynpro fields is as follows:

Name

Type

Format

output

I/O

CHAR

ok_code

OK

OK

The input option for the screen field output is switched off in Screen Painter.

The screen flow logic is as follows:





PROCESS BEFORE OUTPUT.
  MODULE init_screen_0100.
PROCESS AFTER INPUT.
  MODULE user_command_0100.


            

The module init_screen_0100 sets the dialog status status_0100 and a title 100 at PBO time. The dialog status is created using Menu Painter as follows:

Menu Bar

Menu Demo:

Function Code

Text

SAVE

Save

PRINT

Print

DELETE

Delete

EXIT

Exit

Menu Edit:

Function Code

Text

MARK

Select

SELE

Choose

SEARCH

Find

SEARCH+

Find Next

TOP

First Page

PAGE_UP

Previous Page

PAGE_DOWN

Next Page

BOTTOM

Last Page

CANCEL

Cancel

Menu Goto:

Function Code

Text

BACK

Back

Menu Extras:

Function Code

Text

FUNCT_F5

Function 1

FUNCT_F6

Function 2

FUNCT_F7

Function 3

FUNCT_F8

Function 4

Menu Environment:

Function Code

Text

MENU_1

Menu 1

MENU_2

Menu 2

MENU_3

Menu 3

Standard Toolbar

Icon

Function Code

Text

SAVE

Save

BACK

Back

EXIT

Exit

CANCEL

Cancel

PRINT

Print

SEARCH

Find

SEARCH+

Find Next

PAGE_UP

Previous Page

PAGE_DOWN

Next Page

BOTTOM

Last Page

CANCEL

Cancel

Pushbutton Toolbar

Position

Function Code

Text

1

SELE

2

MARK

3

DELETE

4

FUNCT_F5

Function 1

5

FUNCT_F6

Function 2

Function Keys

Key

Function Code

Text

Icon

F2

SELE

Choose

F9

MARK

Select

Shift+F2

DELETE

Delete

F5

FUNCT_F5

Function 1

F6

FUNCT_F6

Function 2

F7

FUNCT_F7

Function 3

F8

FUNCT_F8

Function 4

All function codes exist as menu entries, but not all of them are assigned to function keys. The function codes in the standard toolbar activate the icons and are automatically assigned to their function keys. Some of the additional function keys are assigned to the application toolbar.

The module user_command_0100 assigns the content of the field ok_code to the auxiliary variable save_ok, and ok_code is initialized. This should always happen, since it ensures that the dynpro field ok_code is always initialized before PBO time and cannot contain any wrong values. Then, the function code chosen is assigned to the field output and displayed in the corresponding screen field, except in the case of BACK, EXIT, and CANCEL. The latter exits the program.

The function code SELE can be passed to the ABAP program in the following ways:

  • When Choose is chosen in the Edit menu.

  • When the pushbutton is chosen in the application toolbar.

  • When the F2 key is chosen on the keyboard.

  • When the right-hand mouse button is pressed Choose is chosen.

  • When the screen field of output is double-clicked.

  • When SELE is entered in the command field and ENTER is chosen.

The other function codes are passed in accordance with their definition, but without the double-click function.