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 quick info 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 quick info 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:
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.
This parameter allows you to enter a text that will appear after the icon on the screen.
In this parameter, you can specify a quick info text, which appears whenever the mouse pointer is positioned over the icon.
This flag switches the quick info 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.
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:
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 value 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 quick info is then displayed on the screen. When the user chooses Continue, the contents of the field value are changed in the PAI, and consequently a new icon is defined in the PBO event. The following icons and texts are displayed:
The quick info text is 'Status'for all of the icons.