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:
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 quickinfo text, which appears whenever the mouse pointer is positioned over the icon.
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.
DATA value TYPE i VALUE 1.
DATA: status_icon TYPE
icon_name(20) TYPE c,
icon_text(10) TYPE c.
CALL SCREEN 100.
MODULE set_icon OUTPUT.
SET PF-STATUS 'SCREEN_100'.
icon_name = 'ICON_GREEN_LIGHT'.
icon_text = text-003.
icon_name = 'ICON_YELLOW_LIGHT'.
icon_text = text-002.
icon_name = 'ICON_RED_LIGHT'.
icon_text = text-001.
name = icon_name
text = icon_text
info = 'Status'
add_stdinf = 'X'
result = status_icon
icon_not_found = 1
outputfield_too_short = 2
OTHERS = 3.
MESSAGE e888(sabapdocu) WITH text-004.
MESSAGE e888(sabapdocu) WITH text-005.
MESSAGE e888(sabapdocu) WITH text-006.
MODULE cancel INPUT.
value = 2.
value = 3.
value = 1.
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 AFTER INPUT.
MODULE cancel AT EXIT-COMMAND.
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:
The quickinfo text is ‘Status’ for all of the icons.