ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Accesses →  Open SQL →  Open SQL - Read Accesses →  SELECT →  SELECT - WHERE →  WHERE - sql_cond → 

Short Reference

sql_cond - IN seltab

Syntax

... col [NOT] IN seltab ...

Effect

This expression is true if the value of the column col is (not) in the result set described in the rows of the selection table seltab. Any internal table with a row type that corresponds to that of a selection table can be specified as the selection table seltab. This includes, in particular, ranges tables.

The selection table is evaluated in the same way as in comparison expressions apart from the fact that in comparisons with the operators CP and NP the WHERE condition is case-sensitive, whereas in other comparison expressions it is not. The wildcard characters "*" and "+" of the selection options "CP" and "NP" are converted to the OpenSQL wildcard characters "%" and "_", whereby the escape character "#" is also handled correctly. If "%" and "_" are contained in the template, an OpenSQL escape character is generated.

Notes

Example

A selection table is filled as follows (the order of the rows is not important):

SIGN  OPTION  LOW              HIGH
---------------------------------------
I     EQ      01104711
I     BT      10000000         19999999
I     GE      90000000
E     EQ      10000911
E     BT      10000810         10000815
E     CP      1%2##3#+4++5*

The following WHERE condition is generated from this:

... ( ID = '01104711'                      OR
      ID BETWEEN '10000000' AND '19999999' OR
      ID >= '90000000' )                     AND
    ID <> '10000911'                         AND
    ID NOT BETWEEN '10000810' AND '10000815' AND
    ID NOT LIKE '1#%2##3+4__5%' ESCAPE '#'   ...

Example

Reads flights with a primary key that corresponds to the user entries on the selection screen.

DATA spfli_wa TYPE spfli.

SELECT-OPTIONS: s_carrid FOR spfli_wa-carrid NO INTERVALS
                                             NO-EXTENSION,
                s_connid FOR spfli_wa-connid NO INTERVALS
                                             NO-EXTENSION.

SELECT SINGLE *
       FROM spfli
       INTO spfli_wa
       WHERE carrid IN s_carrid AND
             connid IN s_connid.




Continue
Selection Tables in the WHERE Clause