Filling the Selection Screen of a Called Program 

When you start an executable program, the standard selection screen normally appears, containing the selection criteria and parameters of both the logical database connected to the program and of the program itself (see Direct Execution - Reports). When you start an executable program using SUBMIT, there are various additions that you can use to fill the input fields on the selection screen:

SUBMIT... [VIA SELECTION-SCREEN]
           [USING SELECTION-SET <var>]
           [WITH <sel> <criterion>]
           [WITH FREE SELECTIONS <freesel>]
           [WITH SELECTION-TABLE <rspar>].

These options have the following effects:

The selection screen of the called executable program (report) appears. If you transfer values to the program using one or more of the other options, the corresponding input fields in the selections screen are filled. The user can change these values. By default, the system does not display a selection screen after SUBMIT.

This option tells the system to start the called program with the variant <var>.

Use this option to fill individual elements <sel> of the selection screen (selection tables and parameters). Use one of the elements <criterion>:

If <sel> is a selection criterion, use <op> to fill the OPTION field, <f> to fill the LOW field, and <s> to fill the SIGN field of the selection table <sel> in the called program.

If <sel> is a parameter, you can use any operator for <op>. The parameter <sel> is always filled with <f>.

<f 1 > is transferred into the LOW field, <f 2 > into the HIGH field, and <s> into the SIGN field of the selection table <sel> in the called program. If you omit the NOT option, the system places the value BT into the OPTION field; if you use NOT, the system fills OPTION with NB.

This addition fills the selection table <sel> in the called program with the values of the table <seltab> in the calling program. Table <seltab> must have the structure of a selection table. Use the RANGES statement to create selection tables.

To use this option, both calling and called programs must be connected to a logical database that supports dynamic selections. In the calling program, use the function modules FREE_SELECTIONS_INIT and FREE_SELECTIONS_DIALOG. They allow the user to enter dynamic selections on a selection screen. One export parameter of these function modules has structure RSDS_TEXPR from the RSDS type group. Transfer the values of this export parameter by means of the internal table <freesel> of the same structure to the called report.

You need an internal table <rspar> with the Dictionary structure RSPARAMS. The table then consists of the following six fields:

This table can be filled dynamically in the calling program with all of the required values for the selection screen of the called program. If the name of a selection criterion appears more than once, the system creates a multiple-line selection table for that criterion in the called program. If the name of a parameter appears more than once, the system uses the last value. Note that LOW and HIGH have type C, so that the system executes type conversions to the criteria of the called program. This is important for date fields, for example. Before your program is used in a live context, you should check it using the VIA SELECTION-SCREEN addition.

Except for WITH SELECTION-TABLE, you can use any of the above options several times and in any combination within a SUBMIT statement. In particular, you can use the WITH <sel> option several times for one single criterion <sel>. In the called program, the system appends the corresponding lines to the selection tables used. For parameters, it uses the last value specified. The only combination possible for the WITH SELECTION-TABLE option is USING SELECTION-SET.

If the input fields on the selection screen are linked to SPA/GPA parameters, you can also use this technique to pass values to the selection screen (see Passing Data Between Programs).

The following executable program (report) creates a selection screen containing the parameter PARAMET and the selection criterion SELECTO:

REPORT REP1.
DATA NUMBER TYPE I.
PARAMETERS      PARAMET(14).
SELECT-OPTIONS  SELECTO FOR NUMBER.

The program REP1 is called by the following program using various parameters:

REPORT REP2 NO STANDARD PAGE HEADING.

DATA: INT TYPE I,
      RSPAR LIKE RSPARAMS OCCURS 10 WITH HEADER LINE.

RANGES SELTAB FOR INT.

WRITE: 'Select a Selection!',
     / '--------------------'.
SKIP.

FORMAT HOTSPOT COLOR 5 INVERSE ON.
WRITE: 'Selection 1',
     / 'Selection 2'.

AT LINE-SELECTION.
  CASE SY-LILLI.
    WHEN 4.
      SELTAB-SIGN = 'I'. SELTAB-OPTION = 'BT'.
      SELTAB-LOW  = 1.   SELTAB-HIGH   = 5.
      APPEND SELTAB.
      SUBMIT REP1 VIA SELECTION-SCREEN
                      WITH PARAMET EQ 'Selection 1'
                      WITH SELECTO IN SELTAB
                      WITH SELECTO NE 3
                      AND RETURN.
    WHEN 5.
      RSPAR-SELNAME = 'SELECTO'. RSPAR-KIND = 'S'.
      RSPAR-SIGN = 'E'. RSPAR-OPTION = 'BT'.
      RSPAR-LOW  = 14.  RSPAR-HIGH = 17.
      APPEND RSPAR.
      RSPAR-SELNAME = 'PARAMET'. RSPAR-KIND = 'P'.
      RSPAR-LOW  = 'Selection 2'.
      APPEND RSPAR.
      RSPAR-SELNAME = 'SELECTO'. RSPAR-KIND = 'S'.
      RSPAR-SIGN = 'I'. RSPAR-OPTION = 'GT'.
      RSPAR-LOW  = 10.
      APPEND RSPAR.
      SUBMIT REP1 VIA SELECTION-SCREEN
                      WITH SELECTION-TABLE RSPAR
                      AND RETURN.
  ENDCASE.

When you start the program, the following basic list appears:

After clicking once on the first hotspot, the selection screen of SAPMZTS1 looks like this:

After clicking once on the second hotspot, the selection screen of SAPMZTS1 looks like this:

For both calls of REP1, the system transfers values that lead to two-line selection tables SELECTO. The second line appears in the respective dialog box Multiple Selection for SELECTO. Without the VIA SELECTION-SCREEN option of the SUBMIT statement, PARAMET and SELECTO would be filled accordingly in REP1, but they would not be displayed.