Logical Expressions - Comparison with a Selection Criterion

f [NOT] IN sel checks whether the current contents of the field f are in the set described by the selection criterion sel (internal table). The table sel must have a fixed predefined structure.

... BEGIN OF sel,
      SIGN(1),
      OPTION(2),
      LOW  LIKE f,
      HIGH LIKE f,
    END   OF sel.

The declarations

automatically generate an internal table sel with this structure.

The components of sel have the following meaning:

  1. SIGN contains 'I' for "Inclusive" or 'E' for "Exclusive".


  2. OPTION contains one of the following operators:

    EQ (Equal to)
    BT (Between ... and ...)
    CP (Contains pattern)
    LE (Less than or equal to)
    GE (Greater than or equal to)
    NE (Not equal to)
    NB (Not between ... and ...)
    NP (Does not contain pattern)
    GT (Greater than)
    LT (Less than)


  3. LOW contains the comparison value; with BT, this is the lower limit of the range.


  4. With BT and NB, HIGH contains the higher limit of the range.


Note

Each line of the table sel describes a set.
The set defined by the entire table sel is the union of "inclusive sets" (lines with SIGN = 'I') minus the union of "exclusive sets" (lines with SIGN = 'E').
If no lines exist with SIGN = 'I', the union of "inclusive sets" is set to its maximum size.
If no lines exist with SIGN = 'E', the union of "exclusive sets" is empty.
If sel is empty, sel defines the whole set, i.e. the condition f IN sel is always satisfied.

Example

Contents of table sel:

SIGN | OPTION | LOW   | HIGH
----------------------------
I    | BT     | 1     | 6
E    | BT     | 4     | 7
I    | EQ     | 7     |
I    | EQ     | 9     |
E    | EQ     | 1     |


The set described by sel contains the numbers 2, 3 and 9.

Note

The logical expression is satisfied whenever the table sel is empty.

Short form:

Instead of "f IN sel", you can use the short form "sel" if f is the reference field (... FOR f) for the selection criterion (SELECT-OPTION) sel.

Example

DATA SFLIGHT_WA TYPE SFLIGHT.
SELECT-OPTIONS S_FLDATE FOR SFLIGHT_WA-FLDATE.
...
IF S_FLDATE. ... ENDIF.

is equivalent to

IF SFLIGHT_WA-FLDATE IN S_FLDATE. ... ENDIF.

Note

With the options CP and NP, the LOW and HIGH fields must be of type C, and LOW must contain at least one wildcard character. In this context, + represents a single character, while * represents any character string, even if it is blank.
CP and NP are the only options where + and * act like this. Therefore, the line

I BT A*   D*

in no way defines a set of records starting with all those which begin with " A" and ending with all those which begin with "D", but rather the set of all records which are greater than or equal to the single values " A*" and less than or equal to "D*". This set is smaller since, if the character "Z" in the character set is greater than " *" and the value "DZ" starts with "D", it is not part of the defined set.

Additional help

Checking Selection Criteria