asic form
AT SELECTION-SCREEN.
Additions
1. … ON psel
2. … ON END OF sel
3. … ON VALUE-REQUEST FOR psel_low_high .
4. … ON HELP-REQUEST FOR psel_low_high
5. … ON RADIOBUTTON GROUP radi
6. … ON BLOCK block
7. … OUTPUT
Effect
This event only makes sense in reports, i.e. in programs set to type 1 in the attributes. Type 1 programs are started via a logical database and always have a selection screen where the user can specify the database selections.
The event is processed when the selection screen has been processed (at the end of PAI ).
If an error message ( MESSAGE Emnr ) is sent during the event, all fields on the selection screen become ready for input.
After further user input, AT SELECTION-SCREEN is executed again.
Note
You should only perform very expensive checks with AT SELECTION-SCREEN if the program is then started (not every time the user presses ENTER). Here, you can read the system field SSCRFIELDS-UCOMM (provided a statement TABLES SSCRFIELDS exists). If the field has one of the values ‘ONLI’ (= Execute) or ‘PRIN’ (= Execute and Print), the report is then started, i.e. the selection screen is closed and the processing continues with START-OF-SELECTION . Remember that the selection screen (and thus also AT SELECTION-SCREE N ) is also processed in variant maintenance and with SUBMIT VIA JOB . You can determine which of these applies by calling the function module RS_SUBMIT_INFO .
Addition 1
… ON psel
Effect
This event is assigned to the selection screen fields corresponding to the report parameter or selection criterion psel .
If the report starts an error dialog at this point, precisely these fields become ready for input.
Addition 2
… ON END OF sel
Effect
For each selection criterion sel on the selection screen, you can call a further screen by pressing a pushbutton. On this screen, you can enter any number of single values and ranges for the selection criterion sel .
When this screen has been processed (i.e. at the end of PAI for this screen), the event AT SELECTION-SCREEN ON END OF sel is executed.
At this point, all the values entered are available in the internal table sel .
Addition 3
… ON VALUE-REQUEST FOR psel_low_high
Effect
With this addition, the field psel_low_high is either the name of a report parameter or of the form sel-LOW or sel-HIGH , where sel is the name of a selection criterion. The effect of this is twofold:
The pushbutton for F4 (Possible entries) appears beside the appropriate field.
When the user selects this pushbutton or presses F4 for the field, the event is executed. You can thus implement a self-programmed possible entries routine for the input/output fields of the selection screen. If the program contains such an event and the user presses F4 , the system processes this rather than displaying the check table or the fixed values of the Dictionary field – even if the report parameter or the selection option with LIKE or FOR points to a Dictionary field. You can, for example, use the CALL SCREEN statement to display a selection list of possible values. The contents of the field psel_low_high at the end of this processing block are copied to the appropriate input/output field.
This addition is only allowed with report-specific parameters (PARAMETERS ) or selection options (SELECT-OPTIONS ). For database-specific parameters or selection options, you can achieve the same effect by using the addition VALUE-REQUEST FOR … with the key word PARAMETERS or SELECT-OPTIONS in the include DBxyzSEL (where xyz = name of logical database). In this case, you must program the value help in the database program SAPDBxyz .
Addition 4
… ON HELP-REQUEST FOR psel_low_high
Effect
As with the addition ON VALUE-REQUEST the field psel_low_high is either the name of a report parameter or of the form sel-LOW or sel-HIGH , where sel is the name of a selection criterion. When the user presses F1 on the relevant field, the subsequent processing block is executed. You can thus implement a self-programmed help for the input/output fields of the selection screen. If the program contains such an event and the user presses F1 , the system processes this rather than displaying the documentation of the Dictionary field – even if the report parameter or the selection option with LIKE or FOR points to a Dictionary field.
This addition is only allowed with report-specific parameters (PARAMETERS ) or selection options (SELECT-OPTIONS ). For database-specific parameters or selection options, you can achieve the same effect by using the addition HELP-REQUEST FOR … with the key word PARAMETERS or SELECT-OPTIONS in the include DBxyzSEL (where xyz = name of logical database). In this case, you must program the help in the database program SAPDBxyz .
Addition 5
… ON RADIOBUTTON GROUP radi
Effect
This event is assigned to the radio button groups on the selection screen defined by PARAMETERS par RADIOBUTTON GROUP radi .
If the report starts an error dialog at this point, precisely these fields of the radio button group radi become ready for input again.
Addition 6
… ON BLOCK block
Effect
This event is assigned to the blocks on the selection screen defined by SELECTION-SCREEN BEGIN/END OF BLOCK block .
If the report starts an error dialog at this point, precisely these fields of the block block become ready for input again.
Note
In which sequence are the events AT SELECTION-SCREEN ON psel … , AT SELECTION-SCREEN ON RADIOBUTTON GROUP … , AT SELECTION-SCREEN ON BLOCK … , AT SELECTION-SCREEN processed?
The AT SELECTION-SCREEN ON psel … events assigned to the parameters or selection options are executed in the sequence they are declared in the program, i.e. in the sequence they appear on the selection screen.
The events assigned to the radio button groups are executed according to the first parameter of the radio button group.
The events assigned to the blocks are executed “from the inside to the outside”.
Example
SELECT-OPTIONS SEL0 FOR SY-TVAR0.
SELECTION-SCREEN BEGIN OF BLOCK BL0.
SELECT-OPTIONS SEL1 FOR SY-TVAR1.
SELECTION-SCREEN BEGIN OF BLOCK BL1.
PARAMETERS P0 RADIOBUTTON GROUP RADI.
PARAMETERS P1 RADIOBUTTON GROUP RADI.
SELECTION-SCREEN BEGIN OF BLOCK BL2.
PARAMETERS P3.
SELECTION-SCREEN END OF BLOCK BL2.
SELECT-OPTIONS SEL2 FOR SY-TVAR2.
SELECTION-SCREEN END OF BLOCK BL1.
SELECTION-SCREEN END OF BLOCK BL0.
Sequence:
AT SELECTION-SCREEN ON…
SEL0
SEL1
RADIOBUTTON GROUP RADI
P3
BLOCK BL2
SEL2
BLOCK BL1
BLOCK BL0
AT SELECTION-SCREEN is executed at the very end.
Addition 7
… OUTPUT
Effect
This event is executed at PBO of the selection screen every time the user presses ENTER – in contrast to INITIALIZATION . Therefore, this event is not suitable for setting selection screen default values. Also, since AT SELECTION-SCREEN OUTPUT is first executed after the variant is imported (if a variant is used) and after adopting any values specified under SUBMIT in the WITH clause, changing the report parameters or the selection options in AT SELECTION-SCREEN OUTPUT would destroy the specified values.
Here, however, you can use LOOP AT SCREEN or MODIFY SCREEN to change the input/output attributes of selection screen fields.
Example
Output all fields of the SELECT-OPTION NAME highlighted:
SELECT-OPTIONS NAME FOR SY-REPID MODIF ID XYZ.
….
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
CHECK SCREEN-GROUP1 = ‘XYZ’.
SCREEN-INTENSIFIED = ‘1’.
MODIFY SCREEN.
ENDLOOP.
The addition MODIF ID XYZ to the key word SELECT-OPTIONS assigns all fields of the selection option NAME to a group you can read in the field SCREEN-GROUP1 . At PBO of the selection screen, all these fields are then set to highlighted.