Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Program Flow Logic →  Expressions and Functions for Conditions →  log_exp - Logical Expressions →  rel_exp - Comparison Expressions →  rel_exp - Relational Operators →  rel_exp - Relational Operators for All Data Types 

rel_exp - Tabular Relational Operator IN

Other versions: 7.31 | 7.40 | 7.54

Syntax


... operand [NOT] IN seltab ...

Effect

In a comparison expression with relational operator IN, the conditions of a selection table or a table with this layout are checked, that is whether an operand operand meets the conditions of the rows in the selection table or, with addition NOT, does not meet them. The table-like comparison expression is equivalent to a join using binary or ternary comparison expressions whose number is determined by the number of rows in the internal table.

As a selection table seltab, any internal table can be specified whose row type matches that of a selection table, or a functional method with the corresponding type of return value. This includes, in particular, ranges tables. The selection table can be of any table category. For the layout 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 exception that cannot be handled is raised. If the selection table is initial, the comparison expression is always true.

Each row in a non-initial selection table is included in the join using one of the following comparison expressions. Depending on the operator in the column option, this involves a comparison between two operands using a binary relational operator or the delimitation of an interval using the ternary operator BETWEEN.

  • The operators "EQ", "NE", "GE", "GT", "LE", and "LT" produce a comparison of sizes:

    ... operand {EQ|NE|GE|GT|LE|LT} seltab-low ...

    The relational operator corresponds to the content of the column seltab-option and as the right operand, the content of column seltab-low is used.
  • The operators "CP" and "NP" produce a string comparison:

    ... operand {CP|NP} operand

    The relational operator matches the content of the column seltab-option and the content of the columns seltab-low and seltab-high is concatenated as the right operand.
  • The operators "BT", "NB" produce a delimitation of an interval:

    ... operand [NOT] BETWEEN seltab-low AND seltab-high ...

    The comparison is executed without addition NOT, if the content of the column seltab-option is "BT", and with NOT, if it is "NB". For the interval boundaries, the content of the columns seltab-low and seltab-high is used.

operand is a general expression position and the usual comparison rules apply to operand and the columns low and high of the selection table. The comparison expressions of the individual rows are joined as a logical expression in accordance with the following hierarchy:

  • The expressions of all rows that contain "I" in the column sign are joined using OR. If there are no rows that contain "E" in the column sign, this represents the entire logical expression.
  • The expressions of all rows that contain "E" in the column sign are joined using OR and then negated using NOT. If there are no rows that contain "I" in the column sign, this represents the entire logical expression.
  • If the content "I" and the content "E" are both in the column sign, AND is used to join the logical expression that results from step 1 with the logical expression from step 2

  • Notes

    • These rules above can be interpreted in such a way that the rows containing "I" or "E" in the column sign describe two value sets. The set for "I" is the inclusive set, the set for "E" is the exclusive set. By subtracting the exclusive set from the inclusive set, a result set is calculated that contains all values for which the entire logical expression is true.

    • The operator IN is, due to its implementation using binary relational operators, not suitable for selecting natural-language text content.

    Continue

    Comparison with Selection Table - Example