Show TOC

Selection Tables in Logical ExpressionsLocate this document in the navigation structure

Use

To check if the value of a field meets the conditions in a selection table, you can use the following special logical expression :

... f IN selcrit ....

This logical expression is true if the contents of field f meet the conditions stored in selection table seltab . f can be any elementary field.

If field f is identical to the field for which selection table seltab has been declared using SELECT-OPTIONS , you can use the following shortened form for the logical expression:

... selcrit ....

        


        
REPORT demo_logical_expr_seltab_1.
        
DATA wa_carrid TYPE spfli-carrid.
        
SELECT-OPTIONS airline FOR wa_carrid.
        
WRITE: 'Innerhalb'(001), 'Außerhalb'(002).
        
SELECT carrid FROM spfli INTO wa_carrid.
        
IF wa_carrid IN airline.
        
WRITE: / wa_carrid UNDER 'Innerhalb'(001).
        
ELSE.
        
WRITE: / wa_carrid UNDER 'Außerhalb'(002).
        
ENDIF.
        
ENDSELECT.
        


        


         

If the selection table is filled as follows:

SIGN

OPTION

LOW

HIGH

I

BT

DL

UA

E

EQ

LH

The list output appears as follows:

In the SELECT loop, all rows are read from database table SPFLI. If the IF statement is used, the program flow is branched into two statement blocks depending on the logical expression. The shortened form IF AIRLINE is also possible in this program.

        


        


        
REPORT demo_logical_expr_seltab_2.
        
DATA wa_spfli TYPE spfli.
        
SELECT-OPTIONS: s_carrid FOR wa_spfli-carrid,
        
s_cityfr FOR wa_spfli-cityfrom,
        
s_cityto FOR wa_spfli-cityto,
        
s_connid FOR wa_spfli-connid.
        
SELECT * FROM spfli INTO wa_spfli.
        
CHECK: s_carrid,
        
s_cityfr,
        
s_cityto,
        
s_connid.
        
WRITE: / wa_spfli-carrid, wa_spfli-connid,
        
wa_spfli-cityfrom, wa_spfli-cityto.
        
ENDSELECT.
        


         

After starting the program, the selection screen appears, on which the user might fill the input fields as follows:

The list then appears as follows:

In the SELECT loop, all rows are read from database table SPFLI. The system lists only those rows that meet the conditions in the selection tables. The system leaves the loop pass after the CHECK statement. The CHECK statement uses the shortened forms of the logical expressions. The long forms are:

        


        


        


        
CHECK: wa_spfli-carrid IN s_carrid,
        
wa_spfli-cityfr IN s_cityfr,
        
wa_spfli-cityto IN s_cityto,
        
spfli-connid IN s_connid.