Entering content frame

Status icons Locate the document in its SAP Library structure

Status icons are display elements that you can use to represent the state of a program graphically. In principle you can use any of the icons available in the SAP GUI but the choice should be limited to those icons specifically for this purpose.

You can only create status icons in the graphical Screen Painter. When you create one, you assign a name and a screen field to it. This screen field is known as a status field. The visible length of the screen field determines the amount of space that the icon can take up on the screen. As well as the icon itself, you can also place text in the field. The actual length (defLg) of the status field must be long enough for the internal representation of the icon, plus any text and quickinfo text that you specify. When you create the status icon in the Screen Painter, a placeholder appears on the screen. You must specify the icon itself and its text and quickinfo text in the PBO event of your ABAP program.

In order to define the icon in your ABAP program, you must create a field with the same name as the status field on the screen and the ABAP Dictionary type ICONS-TEXT. You can then fill this field with the required technical information in the PBO event. When the screen is displayed, the information is transferred to the status field and the icon appears.

To fill the field in your ABAP program, use the function module ICON_CREATE. It has the following import parameters:

        surname

The name of the required icon. These are listed in the include program <ICON>, or the corresponding input help in the Screen Painter or Menu Painter.

        text

This parameter allows you to enter a text that will appear after the icon on the screen.

        info

In this parameter, you can specify a quickinfo text, which appears whenever the mouse pointer is positioned over the icon.

        add_stdinf

This flag switches the quickinfo display on or off.

The function module converts these parameters into a single string, which is returned in the export parameter result. When you assign the result parameter to the status field, it contains all the information required to display the status icon.

Example

Status icons

REPORT demo_dynpro_status_icons.

DATA value TYPE i VALUE 1.

DATA: status_icon TYPE icons-text,
      icon_name(20) TYPE c,
      icon_text(10) TYPE c.

CALL SCREEN 100.

MODULE set_icon OUTPUT.

  SET PF-STATUS 'SCREEN_100'.

  CASE value.
    WHEN 1.
      icon_name = 'ICON_GREEN_LIGHT'.
      icon_text =  text-003.
    WHEN 2.
      icon_name = 'ICON_YELLOW_LIGHT'.
      icon_text =  text-002.
    WHEN 3.
      icon_name = 'ICON_RED_LIGHT'.
      icon_text =  text-001.
  ENDCASE.

  CALL FUNCTION 'ICON_CREATE'
       EXPORTING
            name                  = icon_name
            text                  = icon_text
            info                  = 'Status'
            add_stdinf            = 'X'
       IMPORTING
            result                = status_icon
       EXCEPTIONS
            icon_not_found        = 1
            outputfield_too_short = 2
            OTHERS                = 3.

  CASE sy-subrc.
    WHEN 1.
      MESSAGE e888(sabapdocu) WITH text-004.
    WHEN 2.
      MESSAGE e888(sabapdocu) WITH text-005.
    WHEN 3.
      MESSAGE e888(sabapdocu) WITH text-006.
  ENDCASE.

ENDMODULE.

MODULE cancel INPUT.
  LEAVE PROGRAM.
ENDMODULE.

MODULE change.
  CASE value.
    WHEN 1.
      value = 2.
    WHEN 2.
      value = 3.
    WHEN 3.
      value = 1.
  ENDCASE.

ENDMODULE.

The next screen (statically defined) for screen 100 is 100. It has the following static layout:

This graphic is explained in the accompanying text

The screen contains a status field called status_icon with a visible length of 12 and defined length 26. The status icon and the space for the text are represented by placeholders in the Screen Painter.

The screen flow logic is as follows:

PROCESS BEFORE OUTPUT.
  MODULE set_icon.

PROCESS AFTER INPUT.
  MODULE cancel AT EXIT-COMMAND.
  MODULE change.

The dialog module set_icon passes various values to the function module ICON_CREATE, depending on the values of the fields in the program. The status field status_icon is filled with the contents of the export parameter result of the function module. The corresponding icon with its text and quickinfo is then displayed on the screen. When the user chooses Continue, the contents of the field valueare changed in the PAI, and consequently a new icon is defined in the PBO event. The following icons and texts are displayed:

This graphic is explained in the accompanying text  Low

This graphic is explained in the accompanying text  Middle

This graphic is explained in the accompanying text  High

The quickinfo text is ‘Status’ for all of the icons.

 

 

 

Leaving content frame