... [operand [NOT] IN] seltab ...
In a logical expression with language element IN, the conditions of a selection table are checked.
The logical expression checks whether an operand operand meets the conditions of a selection table or, with addition NOT (as of release 6.10), does not meet them.
For operand, you can use data objects, predefined functions (as of release 6.10) and functional methods. As a selection table seltab, you can specify any internal table whose row type matches that of a selection table, or a functional method with the respective type of return value. This especially includes ranges tables. As of release 6.10, the selection table can be of any kind. Before release 6.10, only standard tables were allowed.
For the structure of a selection table, refer to section SELECT-OPTIONS. The evaluation of a selection table requires the table to contain the valid values specified in that section in the columns sign and option. If the selection table contains invalid values, an untreatable exception occurs. If the selection table is initial, the logical expression is always true.
Every row of the selection table represents a logical expression. Depending on the operator in column option, it is either a comparison or an interval selection.
The result of the entire logical expression is determined by the following interlinkage of the individual rows (for the link rules see hier):
These rules can be interpreted in such a way that the rows containing "I" or "E" in the sign column, describe two value sets. The set for "I" is the inclusive set, the set for "E" is the exclusive set. By substracting the exclusive set from the inclusive set, a result set is calculated that contains all values for which the logical expression is true.
If operand is the data object for which the selection table seltab is defined with
SELECT-OPTIONS seltab FOR operand.
then you can omit operand IN and the logical expression has the following short form:
... seltab ...
This short form is possible only for selection tables declared with SELECT-OPTIONS and with static reference to the data object operand.
Filling a selection table s_number and evaluating it in a logical expression. The logical expression is the short form of number IN s_number. The numbers 5, 7, and 9 are output.
DATA number TYPE i.
SELECT-OPTIONS s_number FOR number NO-DISPLAY.
s_number-sign = 'I'.
s_number-option = 'EQ'.
s_number-low = 9.
APPEND s_number TO s_number.
s_number-sign = 'I'.
s_number-option = 'BT'.
s_number-low = 3.
s_number-high = 7.
APPEND s_number TO s_number.
s_number-sign = 'E'.
s_number-option = 'EQ'.
s_number-low = 6.
APPEND s_number TO s_number.
s_number-sign = 'E'.
s_number-option = 'BT'.
s_number-low = 1.
s_number-high = 4.
APPEND s_number TO s_number.
DO 10 TIMES.
number = sy-index.
IF s_number.
WRITE / sy-index.
ENDIF.
ENDDO.