SELECT-OPTIONS
Basic form
SELECT-OPTIONS sel FOR f.
Additions
1. ... DEFAULT g
2. ... DEFAULT g ... OPTION xx ... SIGN s
3. ... DEFAULT g TO h
4. ... DEFAULT g TO h ... OPTION xx ... SIGN s
5. ... MEMORY ID pid
6. ... MATCHCODE OBJECT mobj
7. ... MODIF ID key
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
Effect
Declares a variable selection option.
This statement only makes sense in reports, i.e. in programs defined as
type 1 in the attributes. You can execute reports with the
SUBMIT statement. The statements
SELECT-OPTIONS and
PARAMETERS determine the technical
interface and the user interface. The parameters and selection options
you specify are displayed on the selection screen for the user to enter
values (see also the addition NO-DISPLAY or
SUBMIT without the addition VIA
SELECTION-SCREEN .
sel must be 1 - 8 characters long.
Note
-
This statement defines an internal table sel with a
fixed structure which consists of the fields sel-SIGN ,
sel-OPTION , sel-LOW and sel-HIGH .
-
A report can (by means of an entry in the attributes) be assigned to
a logical database ldb . This means that both the
logical database ldb and the report can define selection options
(and parameters). You define the (database-specific) selection options
in an ABAP/4 include program DBldbSEL (in logical
database maintenance). The system then imports this include
program into the actual logical database access program SAPDBldb
and (partially) into the report. As a result, the database-specific
selection options (and parameters) relevant to the report are available
both to the database program SAPDBldb and to the report.
The 'report-specific' selection options are known only in the report
(not in SAPDBldb ).
Some SELECT-OPTIONS additions are allowed only in
DBldbSEL . The addition 'NO DATABASE SELECTION' can only
be used in the report.
-
Each line of the internal table sel formulates a condition. If
you require precise details about how to formulate these conditions,
see the section on the IN operator under Logical expressions
.
-
If the user enters a value set on the selection screen, the internal
table sel is automatically filled.
You can use normal ABAP/4 statements to read and manipulate the
internal table sel .
-
The values you enter for the database-specific selection options are
passed directly to the database for data selection (i.e. no unwanted
records are read). This also applies to report-specific
SELECT-OPTIONS that refer to a field in a logical database table
defined for dynamic selections (see
also the addition " NO DATABASE SELECTION ").
You must check report-specific selections that refer to other fields
with the CHECK statement (i.e.
unwanted records must first be read from the database and discarded
afterwards). This process is therefore not as efficient as the process
described above.
-
Under "Text elements/selection texts", you should enter a description
for each selection criterion sel . This description is displayed
on the selection screen. If no such text exists, the name sel of
the selection option is displayed instead.
-
The LOW and HIGH fields of a selection option are
displayed in a length up to 18 bytes long (scrollable up to 45 bytes).
If you define a length longer than 45, fields are truncated on the
selection screen after the 45th character. This affects the first line
of the SELECT-OPTIONS table. You can, however, pass longer
selection options to a report if they are specified with the addition
NO-DISPLAY and thus do not appear on the selection screen.
Without NO-DISPLAY , the fields are then truncated whenever the
selection screen is processed in the background
(SUBMIT without VIA SELECTION-SCREEN ).
Example
-
SELECT-OPTIONS PROGRAM FOR SY-REPID.
&ABAP-EFFECT& Suppose you create 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, a line on the selection screen contains
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 select Utilities -> Help sel. screen on the
'Complex Selections' screen.
Note
-
Field attributes on the selection screen.
The input/output fields displayed on the selection screen for entry of
upper and lower limits have the same attributes for type, length or
conversion exits as the field f specified after FOR .
If f is a Dictionary field, the selection screen is regenerated
automatically after most changes to its attributes. The attributes
'Check table' and 'Fixed values' are exceptions to this rule. If these
are changed, you have to generate the program in the ABAP/4
Editor. This also generates the selection screen.
Addition 1
... DEFAULT g
Effect
Proposes the single value g as the default
selection when the report is called.
Notes
-
For each SELECT-OPTION , you can only specify one
DEFAULT .
-
You must specify the default value g in its internal format,
e.g. " SELECT-OPTIONS DATE FOR SY-DATUM DEFAULT '19931224' ", not
" ... DEFAULT '24.12.1993' ".
-
The default value g should normally be a literal because, at
runtime, it is transferred to the selection options table sel so
early that no value can be assigned to the field g . System
fields are an exception here because the system usually assigns values
to them as soon as the report processing starts.
Example
-
SELECT-OPTIONS DATE FOR SY-DATUM DEFAULT SY-DATUM.
Addition 2
... DEFAULT g ... OPTION xx ... 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 )
Effect
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 .
Example
-
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.
Notes
-
For each SELECT-OPTION , you can only specify one
DEFAULT .
-
The option xx and SIGN s must be specified without
quotation marks.
Addition 3
... DEFAULT g TO h
Effect
Proposes the range from g to h when the
report is called.
Note
For each SELECT-OPTION , you can only specify one
DEFAULT .
Addition 4
... DEFAULT g TO h ... OPTION xx ... 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 )
Effect
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 .
Example
-
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.
Notes
-
For each SELECT-OPTION , you can only specify one
DEFAULT .
-
The option xx and SIGN s must be specified without
quotation marks.
Addition 5
... MEMORY ID pid
Effect
On the selection screen, the SET/GET ID pid is
assigned to the left range limit of the selection criterion.
Note
You must specify the memory ID without quotation
marks. It can be up to 3 characters long.
Addition 6
... MATCHCODE OBJECT mobj
Effect
On the selection screen, the matchcode object
mobj is assigned to the left range limit of the selection
criterion.
Note
You must specify the name of the matchcode object without
quotation marks. It can be up to 4 characters long.
Addition 7
... MODIF ID key
Effect
The specified modification group ( SCREEN-GROUP1 ),
which can be used for screen modifications, is assigned to the screen
fields.
Note
You must specify the name of the modification group
without quotation marks. It can be up to 3 characters long.
Example
-
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.
Addition 8
... NO-DISPLAY
Effect
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
selection 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 (see CALL FUNCTION
) or your own screen
(CALL SCREEN .
Addition 9
... LOWER CASE
Effect
The selection is not case-sensitive (i.e. allows upper
and lower case letters).
Addition 10
... OBLIGATORY
Effect
The user must enter a value for this selection (in the
LOW field).
Addition 11
... NO-EXTENSION
Effect
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.
Addition 12
... NO INTERVALS
Effect
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.
Notes
-
On the "Multiple Selection" screen, you can also enter
ranges for selection options with " NO INTERVALS ".
-
By combining this addition with " NO-EXTENSION ", you can
restrict the user to entry of a single value for the selection option,
but with the possibility of also choosing single value options like
'Greater than' or 'Less than or equal'.
-
By using the addition " NO INTERVALS " with
SELECTION-SCREEN BEGIN OF BLOCK
, you can activate the simplified display for all
selection options in a block.
-
The function module SELECT_OPTIONS_RESTRICT allows you to
restrict the set of selection options available for a
SELECT-OPTION (for example, only single values and patterns,
i.e. 'EQ' and 'CP' are allowed). You can also forbid the
leading sign 'E' (= 'Exclude from selection'). This means that
you can considerably restrict the selections which can be entered on
the selection screen.
Addition 13
... NO DATABASE SELECTION
Effect
This addition is allowed only 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 considerable effect on performance.
Addition 14
... VALUE-REQUEST
Addition 15
... VALUE-REQUEST FOR LOW/HIGH
Effect
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:
The affected input/output fields are displayed on the selection
screen with the pushbutton for F4 (possible entries).
When the user presses this button or F4 , this triggers the
FORM routine sel-LOW_VAL or sel-HIGH_VAL 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 F4 and the check table or the
fixed values of the Dictionary field are not displayed. You can, for
example, branch from the routine sel-LOW_VAL or
sel-HIGH_VAL to a function module which offers a selection list
of possible values. At the end of this FORM routine, the
contents of the field sel-LOW or sel-HIGH are copied to
the appropriate input/output field.
Example
-
* 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.
Addition 16
... HELP-REQUEST
Addition 17
... HELP-REQUEST FOR LOW/HIGH
Effect
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). 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.
Example
-
* 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.
Index
© SAP AG 1996