Entering content frameCalling User-Defined Selection Screens Locate the document in its SAP Library structure

You can create user-defined selection screens in executable programs (reports), function modules and module pools. There are three ways how user-defined selection screens can be called.

Call From a Program

From any program in which selection screens are defined, you can call these screens at any point of the program flow using the following statement:

CALL SELECTION-SCREEN <numb> [STARTING AT <x1> <y 1>]
[ENDING AT <x2> <y 2>].

This statement calls selection screen number <numb>. The selection screen called must be defined in the calling program either as the standard selection screen (screen number 1000) or as a user-defined selection screen (any screen number). You must always use CALL SELECTION-SCREEN to call selection screens, and not CALL SCREEN. If you use CALL SCREEN, the system will not be able to process the selection screen.

You can display a user-defined selection screen as a modal dialog box using the STARTING AT and ENDING AT additions. This is possible even if you have not used the AS WINDOW addition in the definition of the selection screen. However, you are recommended to do so, since warnings and error messages that occur during selection screen processing will then also be displayed as modal dialog boxes (see example below).

When it returns from the selection screen to the program, the CALL SELECTION-SCREEN statement sets the return value SY-SUBRC as follows:

Any time a selection screen is processed, the selection screen events are triggered. System field SY-DYNNR of the associated event blocks contains the number of the selection screen that is currently active.

Example

REPORT SELSCREENDEF.

SELECTION-SCREEN BEGIN OF BLOCK SEL1 WITH FRAME TITLE TIT1.
  PARAMETERS: CITYFR LIKE SPFLI-CITYFROM,
CITYTO LIKE SPFLI-CITYTO.
SELECTION-SCREEN END OF BLOCK SEL1.

SELECTION-SCREEN BEGIN OF SCREEN 500 AS WINDOW.
  SELECTION-SCREEN INCLUDE BLOCKS SEL1.
  SELECTION-SCREEN BEGIN OF BLOCK SEL2
WITH FRAME TITLE TIT2.
    PARAMETERS: AIRPFR LIKE SPFLI-AIRPFROM,
AIRPTO LIKE SPFLI-AIRPTO.
  SELECTION-SCREEN END OF BLOCK SEL2.
SELECTION-SCREEN END OF SCREEN 500.

INITIALIZATION.
  TIT1 = 'Cities'.

AT SELECTION-SCREEN.
  CASE SY-DYNNR.
    WHEN '0500'.
      MESSAGE W159(AT) WITH 'Screen 500'.
    WHEN '1000'.
      MESSAGE W159(AT) WITH 'Screen 1000'.
  ENDCASE.

START-OF-SELECTION.
  TIT1 = 'Cities for Airports'.
  TIT2 = 'Airports'.
  CALL SELECTION-SCREEN 500 STARTING AT 10 10.
TIT1 = 'Cities again'.
  CALL SELECTION-SCREEN 1000 STARTING AT 10 10.

This executable program contains definitions for the standard selection screen and the user-defined screen number 500. Selection screen 500 is defined to be displayed as a modal dialog box and contains the SEL1 block of the standard selection screen. Note the phase in which the titles of the screens are defined. For the purpose of demonstration, the program calls warning messages with message class AT during the AT SELECTION-SCREEN event.

When you start the program, the following sequence of screens is displayed:

1. The standard selection screen. If the user chooses Execute, the system displays the warning SCREEN 1000 in the status bar.

This graphic is explained in the accompanying text

2. Once the user has confirmed the warning by choosing Enter, selection screen 500 is called as a modal dialog box. When the user chooses Execute, the system displays the warning SCREEN 500, also in a dialog box.

This graphic is explained in the accompanying text

3. When the user has confirmed this warning, the standard selection screen is called again, but this time as a modal dialog box. Since you cannot define the standard selection screen as a modal dialog box, the warning message displayed when the user chooses Execute appears in the status bar and not as a modal dialog box.

This graphic is explained in the accompanying text

Consequently, you can only exit this selection screen using Cancel, since there is no Enter function in the dialog box to confirm the warning message.

Call as a Report Transaction

When creating transaction codes for report transactions, you can define any user-defined selection screen of the executable program for which you create the transaction code as the initial screen. When the program is then started using the transaction code, the user-defined selection screen and not the standard selection screen is called between the INITIALIZATION and the START-OF-SELECTION event.

Example

You create a report transaction with transaction code SELSCREEN500 for the example program above:

This graphic is explained in the accompanying text

When you call the transaction, the executable program is started directly with selection screen 500 as a full screen. When the user chooses Execute, the warning is displayed as a modal dialog box because selection screen 500 was originally defined as a modal dialog box.

This graphic is explained in the accompanying text

The sequence of screens then continues in the same way as described from point 2 onwards in the above example.

Call as a Dialog Transaction

You can use any selection screen in executable programs and module pools that are called with transaction codes for dialog transactions as the initial screen. The selection screen is then the first screen of a screen sequence.

You must ensure that the program flow moves on to the correct next screen during selection screen processing.

Example

Let us consider the following module pool:

*&----------------------------------------------------*
*& Modulpool SAPMSSLS *
*&----------------------------------------------------*

INCLUDE MSSLSTOP.

INCLUDE MSSLSEVT.

Include MSSLSTOP contains the following definition of selection screen 500:

*&----------------------------------------------------*
*& Include MSSLSTOP *
*&----------------------------------------------------*

PROGRAM SAPMSSLS.

SELECTION-SCREEN BEGIN OF SCREEN 500 AS WINDOW.
  SELECTION-SCREEN BEGIN OF BLOCK SEL1 WITH FRAME.
    PARAMETERS: CITYFR LIKE SPFLI-CITYFROM,
CITYTO LIKE SPFLI-CITYTO.
  SELECTION-SCREEN END OF BLOCK SEL1.
  SELECTION-SCREEN BEGIN OF BLOCK SEL2 WITH FRAME.
    PARAMETERS: AIRPFR LIKE SPFLI-AIRPFROM,
AIRPTO LIKE SPFLI-AIRPTO.
  SELECTION-SCREEN END OF BLOCK SEL2.
SELECTION-SCREEN END OF SCREEN 500.

Include MSSLSEVT processes the AT SELECTION-SCREEN event:

*------------------------------------------------------*
* INCLUDE MSSLSEVT *
*------------------------------------------------------*

AT SELECTION-SCREEN.

  ...

  LEAVE TO SCREEN 100.

When we create a transaction code for program SAPMSSLS, we enter screen 500 as the initial screen.

This graphic is explained in the accompanying text

Transaction SELSCREEN_DIALOG starts the program and displays the selection screen.

This graphic is explained in the accompanying text

You can process the user entries from the selection screen either at the AT SELECTION-SCREEN event, or at a later point in the application logic. When the AT SELECTION-SCREEN event (PAI of the selection screen) has been processed, the program moves on to the next screen 100.

 

 

 

 

 

Leaving content frame