SAP SELECT-OPTIONS ABAP Statements



Get Example source ABAP code based on a different SAP table
  


ID SELECT-OPTIONS
• SELECT-OPTIONS ABAP Statement
• * SELECT-OPTIONS
• + SELECT-OPTIONS

SELECT-OPTIONS
Short Reference

ABAP_SYNTAX
SELECT-OPTIONS selcrit FOR ${dobj$|(name)$}
$[ screen_options$]
$[value_options$]
$[NO DATABASE SELECTION$]
$[ldb_options$].

What does it do?
This declares a selection criterion selcrit for a data object dobj or a type specified in name. Selection criteria are components of a selection screen, which are assigned a selection table in the ABAP program, as well as two input fields and a pushbutton for multiple selection.
The name of the selection criterion selcrit is limited to a maximum of 8 characters. This statement is allowed in the global declaration part of executable programs, function pools, and module pools. In function pools and module pools, the statement is only allowed within the definition of a standalone selection screen. In executable programs, the statement is otherwise automatically assigned to the standard selection screen.
The statement SELECT-OPTIONS has the following effect:
The statement declares a selection table in the program with the name selcrit. A selection table is an internal standard table with header line and standard key. Selection tables can be used to store ranges conditions that link multiple comparison expressions with each other. The content of selection tables can be evaluated in a comparison expression with the comparison operator IN or in a similar expression of a WHERE condition in AB_SQL . Selection tables have the same layout as ranges tables and have the following four columns:
sign of type c and length 1. The content of sign determines for every line whether the result of the condition formulated in the column is included or excluded in the entire resulting set for all lines. Valid values are I for include and E for exclude.
option of type c with length 2. option contains the selection option for the condition of the line in the form of comparison operators. Valid operators are EQ, NE, GE, GT , LE, LT, CP, and NP, if the column high is initial, and BT, NB, if column high is not initial. For the options CP and NP, the data type of the columns low and high must be c, and special rules apply to input on the selection screen.
low of the data type defined after FOR. This column is intended for the comparison value in single comparisons or the lower interval limit for interval selections.
high of the data type defined after FOR. This column is intended for the upper interval limit for interval selections.
Two input fields with the name selcrit-low and selcrit-high are created on the current selection screen using a matching external data type in a new line at positions 35 and 60. The length of the input fields depends on the length of the data type, which is defined after FOR. The maximum length of the input fields is 255. The maximum visible length of the input fields is between 10 and 18, depending on the nesting depth in framed blocks. If the length is greater than the maximum visible length, the content is displayed as movable. An automatically generated output field is displayed in the first possible position in front of the first input field as a label with a length of between 20 and 30 depending on the nesting depth in framed blocks. The output field contains either the name of the selcrit selection criterion or the selection text to which the selection criterion is assigned in the text elements of the program. If the user requests field or input help on the output field using the function key F1 or F4, the same output appears as if one of the input fields were chosen. A multiple selection pushbutton is created after the second input field. If this pushbutton is selected, a dialog box with four tabstrip control pages appears, in which the input fields are again displayed in tabular form in Table Controls. The tabstrip pages are separated based on individual value comparison, interval selections, and settings for the column sign. Users can select an input field with a double-click on the selection screen or use the dialog box for multiple selection. On the selection screen, the value of the column sign can also be chosen. On the dialog box for multiple selection, this is done by selecting the respective tabstrip page. If the selection option is not equal to EQ or BT, it is displayed as an icon in front of the first input field. The color of the icon is green if the content of the column sign is I, and red if it is E. The selection options CP and NP can be selected only if the first input field contains at least one of the wildcard characters * or +. + masks a single character, * masks any character string, even an empty one. If one of these characters is entered, the selection option is automatically set to CP. If CP is set, and all wildcard characters have been removed, the selection option is automatically set to EQ for a user action. This restriction does not apply within the program. When the selection table is evaluated, the column low can also contain a string without wildcard characters for the selection options CP and NP. The properties of the elements on the selection screen can be affected with the statement screen_options or the statement SELECTION-SCREEN .
The first line of the selection table selcrit is linked with the input fields on the selection screen. All lines are displayed in the dialog box for multiple selection. Each time before the selection screen is sent to the selection screen event AT SELECTION-SCREEN OUTPUT, the content of first line in the selection table is transported to the selection screen, with a conversion routine being executed if required. If the length of the columns low and high in the first line of the selection table is greater than 255, the surplus content is cut off on the right. It is only possible for all lines to be transported if the button for multiple selections is selected. A conversion routine might be executed here, and lines might be truncated. Settings for the content of the input fields can be made in value_options. After a user action on the selection screen, the content of the input fields and the selected settings is transported to the first line and the header line of the selection table. After a user action on the dialog box for multiple selections, the content of all input fields and the selected settings are transported to the lines of the selection table. These transports convert the content of character-like fields by default into uppercase letters by default, after which a conversion routine is performed, if required. After each transport, various selection screen events are raised. If a value has been entered in the entry field for the upper interval high, the system automatically checks whether this value is greater than the lower interval limit low following each transport and conversion routine (if performed). If necessary, an error message is sent. This check can be switched off before the selection screen is sent, using the function module RS_SELOPT_NO_INTERVAL_CHECK.
If selection criteria are defined in the selection include of a logical database, further additions ldb_options are necessary or possible.
If, in an executable program, a selection criterion is defined for a component of a node of the linked logical database, declared by TABLES or NODES, and the node in question is intended for dynamic selection on the logical database, the selection table is passed to the logical database by default after selection screen processing, where it is handled as a dynamic selection. Furthermore, in this case, the input fields for the corresponding dynamic selection are displayed directly on the selection screen. Therefore, the user does not need to select the fields using the Dynamic Selections function. This transfer can be suppressed using the addition NO DATABASE SELECTION.



Latest notes:

To avoid undefined system behavior, the header line of a selection table should not be changed in the program. Read access should also be avoided. Instead separate work areas, field symbols, or data references should be used, as always for internal tables.
If a selection criterion is supplied with data when an executable program is called using SUBMIT, a conversion routine is performed for the first line only, while the value of the columns low and high will be truncated at position 255 for the first line only. If the selection criterion is declared with the addition NO-DISPLAY, no conversion routine or truncation will be performed for the first line either.
If the type of the selection criterion is a decimal floating point number that does not refer to a data type in the ABAP Dictionary, the output style preserve scaling is set for the input field of the selection screen. Here, any trailing zeros are preserved in the decimal places. If there is a reference to a data type in the ABAP Dictionary, the output style defined there is used.
If the type of the selection criteria is a packed number type or a decimal floating point number type defined in the ABAP Dictionary, the property sign must be set for the type property, so that negative numbers can be displayed on the selection screen. This setting is only possible for DDIC domains and not for specifying a built-in type directly for DDIC data elements or structure components. If a negative number is entered on the selection screen and this property is not set, the system rejects it with an error message. If the columns low or high contain a negative number when the selection screen is called, an uncatchable exception is raised.
If the type of the selection criterion is a decimal floating point number type defined in the ABAP Dictionary for which the output style currency amount is specified, only numbers with the corresponding amount of decimal places can be entered on the selection screen. If a corresponding ABAP data object contains a number with too many decimal places when the selection screen is called, an uncatchable exception is raised. If the output style is extended currency amount, additional decimal places can be displayed.
The selection option CP is selected automatically when entering escape characters and is undone when removing escape characters only after user input is made in the associated input field on the selection screen. Escape characters in fields whose content is passed to the selection screen from the program do not cause the selection option to be selected automatically.
The columns sign and option of a selection table declared using SELECT-OPTIONS are not related to data types in the ABAP Dictionary. In the case of ranges tables defined in the ABAP Dictionary, these columns refer to the data elements DDSIGN and DDOPTION.
To avoid conflicts with internal names, do not name a selection criterion o. The selection screen events are not raised properly for that name. parameter o. The selection screen events are not raised properly for that name.
ABAP_CAUTION When evaluating input values from selection screens the common rules for dynpros and comparisons must be considered. This involves the handling of lower case letters by dynpros and the comparison rules for character-like data. For some examples, see TITLE .
ABAP_HINT_END

Return to menu