There are 2 main ways to create (and respond to) buttons on a selection screen and using SET PF-STATUS
is NOT one of them...
Buttons on the application tool bar
Up to 5 buttons can be added (or activated) on the application tool bar. The selection screen buildup should include the following coding:
SELECTION-SCREEN FUNCTION KEY 1. SELECTION-SCREEN FUNCTION KEY 2. SELECTION-SCREEN FUNCTION KEY 3.
Which will place 3 buttons on the screen. The texts in the buttons need to be supplied in INITIALIZATION
as follows:
INITIALIZATION. SSCRFIELDS-FUNCTXT_01 = 'Banana button'. SSCRFIELDS-FUNCTXT_02 = '@10@'. SSCRFIELDS-FUNCTXT_03 = '@0S@ Documentation'.
The result will be something like this:
The SSCRFIELDS
structure needs to be declared with TABLES. having done the above, the buttons will appear (with or without Icons, e.g. @10@ pops up as the "I" information icon). Of course responding to the buttons would complete this feature:
AT SELECTION-SCREEN. CASE SSCRFIELDS-UCOMM. when 'FC01'. "Do something when 'FC02'. "Do something else when 'FC03'. "Do something else ENDCASE.
Note: when you like to add Icons to your selection-screen buttons, note the following: The method described above will place an Icon on the button, but the yellow "Quickinfo" text will also display the icon code @AB@
or similar. Here's a way to avoid that:
SSCRFIELDS-FUNCTXT_01(40) = 'Texts for menubar and quickinfo'. SSCRFIELDS-FUNCTXT_01+40(44) = 'Texts for button'. "or icon code SSCRFIELDS-FUNCTXT_01+84 = 'Texts for quickinfo when you want to overrule the default text'.
Buttons in the selection screen itself
If placing buttons in the selection screen itself is what you are looking for, the selection screen buildup should be implemented as follows:
SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN PUSHBUTTON 1(40) pushbut1 USER-COMMAND FC_ONE. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN PUSHBUTTON 42(20) pushbut2 USER-COMMAND FC_TWO. SELECTION-SCREEN END OF LINE.
The variables pushbut1
and pushbut2
are automatically defined by the above statement. They are placeholders for the texts that should be displayed on the buttons, e.g.
INITIALIZATION. pushbut1 = 'Banana button'. pushbut2 = '@0S@ Documentation'.
The result will be something like this:
Responding to the buttons is done much the same as above:
AT SELECTION-SCREEN. CASE SY-UCOMM. when 'FC_ONE'. "Do something when 'FC_TWO'. "Do something else ENDCASE.
and that's really all there is to it !