1. SELECT-OPTIONS
sel FOR f.
2. SELECT-OPTIONS sel FOR (f).
Declaring a variable selection option
Objects defined using this statement can have two purposes:
Defining Complex Selections
SELECT-OPTIONS sel FOR f.
1. ...
DEFAULT g
2. ...
DEFAULT g ... OPTION op ... SIGN s
3.
... DEFAULT g TO h
4.
... DEFAULT g TO h ... OPTION op ... SIGN s
5.
... MEMORY ID pid
6.
... MATCHCODE OBJECT mobj
7. ... MODIF ID modid
8. ...
NO-DISPLAY
9. ...
LOWER CASE
10. ...
OBLIGATORY
11. ...
NO-EXTENSION
12. ...
NO INTERVALS
13. ...
NO DATABASE SELECTION
14.
... VALUE-REQUEST
15.
... VALUE-REQUEST FOR LOW/HIGH
16.
... HELP-REQUEST
17.
... HELP-REQUEST FOR LOW/HIGH
18. ... VISIBLE LENGTH vlen
In this variant, field f determines the technical attributes of the fields LOW and HIGH, and the mask used for these fields on the selection screen. For example, if you specify a numeric reference field, the user cannot enter non-numeric values.
SELECT-OPTIONS PROGRAM FOR SY-REPID.
Creates an internal table PROGRAM with the header line
fields PROGRAM-SIGN, PROGRAM-OPTION,
PROGRAM-LOW and PROGRAM-HIGH.
PROGRAM-LOW and PROGRAM-HIGH
have the same field attributes as SY-REPID. When the report
is executed (if it is a type 1 program called using
SUBMIT
) or the selection screen is called using
CALL SELECTION SCREEN, a line on the selection screen
appears, containing the text 'PROGRAM' or the associated
selection text as well as input fields for PROGRAM-LOW
and PROGRAM-HIGH. At the end of the line, there is a pushbutton
with an arrow. When you press this button, you branch to the 'Complex Selections' screen where you can
enter more selection lines for sel. Here, you can formulate
very complicated selection conditions. For further information about how these entries determine the
result set, see Logical Expressions or choose 'Help on screen' on the 'Multiple selections' screen.
Field attributes on the selection screen.
... DEFAULT g
Proposes the single value g as the default selection when the report is called.
SELECT-OPTIONS DATE FOR SY-DATUM DEFAULT SY-DATUM.
... DEFAULT g ... OPTION op ... SIGN s
(xx is OPTION,
i.e. one of the values
EQ,NE,CP,NP,GE,LT,LE,GT); s
is SIGN, i.e. one of the values I or E)
Similar to "... DEFAULT g", except that the system also
proposes the specified selection option and SIGN.
You
can specify the additions
OPTION and SIGN
in any order or omit them. The standard
OPTION is EQ,
the standard SIGN is I.
DATA CITY(20).
SELECT-OPTIONS SO_CITY FOR CITY DEFAULT 'SAN*'
OPTION CP SIGN E.
On the selection screen, this results in an entry specifying that cities not beginning with "SAN" are selected.
... DEFAULT g TO h
Proposes the range from g to h when the report is called.
... DEFAULT g TO h ... OPTION op ... SIGN s
(op is OPTION,
that is, one of the values
EQ,NE,CP,NP,GE,LT,LE,GT); s
is SIGN, i.e. one of the values I or E).
Similar to "DEFAULT g TO h", except that the system proposes
the specified selection option and SIGN.
You can specify
the additions OPTION and SIGN
in any order or omit them. The default
OPTION is BT,
the default SIGN is I.
DATA WORD(20).
SELECT-OPTIONS SO_WORD FOR WORD DEFAULT 'SPRING' TO 'SUMMER'
OPTION NB SIGN I.
On the selection screen, this results in an entry specifying that the words between "SPRING" and "SUMMER" are excluded.
The DEFAULT option allows you to fill the first line of
the internal table sel with default values before the
selection screen is displayed. If the SELECT-OPTION is
supposed to consist of several lines on the selection screen, and you are using
SUBMIT, , these entries can be placed in the internal
table at INITIALIZATION.
However, it is not enough to fill the header line - you must also add the entries to the table with APPEND.
DATA SBOOK_WA TYPE SBOOK.
SELECT-OPTIONS FL_DATE FOR SBOOK_WA-FLDATE.
INITIALIZATION.
MOVE: 'I' TO FL_DATE-SIGN,
'EQ'
TO FL_DATE-OPTION,
SY-DATUM TO FL_DATE-LOW.
APPEND
FL_DATE.
MOVE: 'BT' TO FL_DATE-OPTION,
'19960101'
TO FL_DATE-LOW,
'19960630' TO FL_DATE-HIGH.
APPEND FL_DATE.
When the selection screen is displayed, FL_DATE already
contains the selection by the single value SY-DATUM (current date) and the interval from January 1 to June 30, 1996.
When you call a user-defined selection screen using
CALL SELECTION-SCREEN, the current contents of the
select-options are displayed and can be changed. You can fill the table with any contents beforehand.
... MEMORY ID pid
On the selection screen, the SPA/GPA ID pid is assigned to the left range limit of the selection criterion.
You must specify the memory ID without quotation marks. It can be up to 3 characters long.
... MATCHCODE OBJECT mobj
On the selection screen, the matchcode object mobj is assigned to the left range limit of the selection criterion.
You must specify the name of the matchcode object without quotation marks. It can be up to 4 characters long.
The specified modification group (SCREEN-GROUP1), which can be used for screen modifications, is assigned to the screen fields.
TABLES SAPLANE.
...
SELECT-OPTIONS S_PTYPE FOR SAPLANE-PLANETYPE MODIF ID ABC.
...
AT
SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'ABC'.
SCREEN-INTENSIFIED
= '1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
... NO-DISPLAY
Does not display the selection on the selection screen. Creates the internal table
sel as with 'normal' selection options and you can then transfer
the selection option with SUBMIT.
These selection options represent a part of the interface which the user does not see on the
selection screen. You can set the values either internally (through the routine
INIT in SAPDBldb
or INITIALIZATION
in the report) or with SUBMIT. These selection options
are also stored for variants.
Sometimes (e.g. when the user has entered particular values for
other select-options or parameters),
you may want to display these undisplayed selection options on the screen so that the user can enter
values. You can do this in the routine PAI of the database program SAPDBldb
(for database-specific selection options) or under
AT SELECTION SCREEN (for report-specific selection
options) by calling a function module (
CALL FUNCTION
) or your own screen (CALL
SCREEN).
Alternatively, you can place the select-option
on a user-defined selection
screen
(and not on the standard screen 1000 displayed when you use
SUBMIT
). You can then call this screen using
CALL SELECTION-SCREEN in AT SELECTION-SCREEN.
... LOWER CASE
The selection is not case-sensitive (i.e. allows upper and lower case letters).
... OBLIGATORY
The user must enter a value for this selection (in the LOW field).
... NO-EXTENSION
The user can only make an entry on one line. Calling the additional "Multiple Selection" screen is not supported and no pushbutton for this appears on the selection screen.
... NO INTERVALS
The selection option is displayed on the selection screen without a 'to' field. The pushbutton for calling
the "Multiple Selection" screen appears immediately after the 'from' field.
This addition thus allows
you to generate a simplified display on the selection screen. This is particularly useful if you are not making any range selections for this selection option.
... NO DATABASE SELECTION
This addition is allowed only in reports and for report-specific SELECT-OPTIONS
which refer to a field
f belonging to a table dbtab
of the logical database. Here, the selections entered by the user are not passed directly to the logical
database unless the logical database supports Dynamic Selections
for dbtab (if Dynamic
Selections for dbtab are not supported, the addition
has no effect.
This addition can be useful if you only want the selections entered by the user
for this SELECT-OPTION to be effective under certain conditions.
However, you should be careful when using it: Since the selections have to be checked with
CHECK after the records have been read, this has a considerably adverse effect on performance.
... VALUE-REQUEST
... VALUE-REQUEST FOR LOW/HIGH
This addition is allowed only for database-specific SELECT-OPTIONS
in the include program DBxyzSEL
(where xyz = logical database name). It allows you to implement self-programmed value help. (To implement
self-programmed value help for report-specific SELECT-OPTIONS,
you can use the event key word AT
SELECTION-SCREEN ON VALUE-REQUEST FOR ...
.) If you specify only VALUE-REQUEST (without
FOR ...), the value help refers to both input/output fields
of the
SELECT-OPTION (i.e. to sel-LOW
and sel-HIGH). Otherwise, it refers only to the specified field. The addition has two effects:
* INCLUDE DBXYZSEL
...
SELECT-OPTIONS S_PTYPE FOR SAPLANE-PLANETYPE VALUE-REQUEST FOR LOW.
...
REPORT SAPDBXYZ DEFINING DATABASE XYZ.
...
TABLES SAPLANE.
...
FORM S_PTYPE-LOW_VAL.
...
CALL FUNCTION '...'.
...
ENDFORM.
... HELP-REQUEST
... HELP-REQUEST FOR LOW/HIGH
Like VALUE-REQUEST, this addition is allowed only for
database-specific
SELECT-OPTIONS in the include
program DBxyzSEL (where xyz = logical database name).
It allows you to implement self-programmed value help. (To implement self-programmed value help
for report-specific SELECT-OPTIONS, you can use the event
key word AT SELECTION-SCREEN
ON HELP-REQUEST FOR ...). If you specify only HELP-REQUEST
(without FOR ...), the help refers to both input/output
fields of the
SELECT-OPTION (i.e. to sel-LOW
and
sel-HIGH) and all other fields linked to the SELECT-OPTIONS:
Text to field between LOW
and
HIGH, assigned comments (SELECTION-SCREEN COMMENT ... FOR FIELD sel). Otherwise, it refers only to the specified field.
When the user presses F1, this triggers
the FORM routine sel-LOW_HLP
or
sel-HIGH_HLP in the database access program SAPDBxyz
(if it exists). If this addition is specified - and even if the SELECT-OPTION
with
FOR points to a Dictionary field - this FORM
routine is executed when the user presses F1 and the documentation
of the Dictionary field is not displayed. You can, for example, branch from the routine
sel-LOW_HLP or sel-HIGH_HLP to a function module which displays its own documentation.
* INCLUDE DBXYZSEL
...
SELECT-OPTIONS S_PTYPE FOR SAPLANE-PLANETYPE HELP-REQUEST.
...
REPORT SAPDBXYZ DEFINING DATABASE XYZ
...
TABLES SAPLANE.
...
FORM S_PTYPE-LOW_HLP.
...
CALL FUNCTION '...'.
...
ENDFORM.
FORM S_PTYPE-HIGH_HLP.
...
CALL FUNCTION '...'.
...
ENDFORM.
... VISIBLE LENGTH vlen
This addition allows you to shorten the visible length of the corresponding screen field on the selection screen to vlen.
SELECT-OPTIONS sel FOR (f).
Additions as in variant 1.
In this variant, (f) must be a field containing the name
of the actual reference field at runtime. The system creates the LOW
and HIGH fields as character fields with length 45. However,
their appearance on the selection screen is inherited from the reference field whose name is contained in field f at runtime.
f must contain the name of an ABAP Dictionary field at runtime.
This variant is only supported for report-specific SELECT-OPTIONS
(unlike the corresponding "dynamic" variant of the LIKE relationship in PARAMETERS).
f must contain the required field name by the time the
parameter is to be displayed for the first time. This means that it must be filled in or before AT
SELECTION-SCREEN OUTPUT of the first call of a selection screen containing sel.
The input entered by the user is stored in
LOW and HIGH
in external format with no formatting sign, that is for example, as YYYYMMDD for a date field, or without thousand separators, and with the period as the decimal separator for a packed number.
The system displays any defined selection text for sel,
otherwise, it uses the text from the ABAP Dictionary field whose name is in f.
You should only use this "dynamic" variant of the FOR
relationship when absolutely necessary, since the selection screen processing is less efficient than with the "static" variant.
The dynamic variant does not support the CHECK sel.
...
DATA FNAME LIKE TABFIELD-LFIELDNAME.
SELECT-OPTIONS SELDYN FOR (FNAME).
...
INITIALIZATION.
FNAME = 'SFLIGHT-SEATSMAX'.
The SELECT-OPTION appears on the selection screen with
the technical attributes of SFLIGHT-SEATSMAX. It also
adopts the
F1 and F4 help of that field.
If FNAME has its own selection text, the system displays
it. Otherwise, it displays the selection text for SFLIGHT-SEATSMAX as defined in the ABAP Dictionary.
PARAMETERS, SELECTION-SCREEN, AT SELECTION-SCREEN, CALL SELECTION-SCREEN