SAP WHERE LOGEXP SELTAB



Get Example source ABAP code based on a different SAP table
  


Short Reference
• IN range_tab ABAP_OSQL_COND
• NOT IN range_tab ABAP_OSQL_COND
• /pt IN range_tab
• _ IN range_tab
• * IN range_tab
• + IN range_tab

ABAP_SQLCOND - IN range_tab

ABAP_SYNTAX
... operand $[NOT$] IN @range_tab ...

What does it do?
This variant of the operator IN checks whether the operands on the left side match a ranges condition in a ranges table. The relational expression is true if the value of the operand operand is (is not) in the result set described in the rows of the ranges table range_tab specified as a host variable.
The following applies to operand:
SQL expressions except for aggregate expressions and window expressions can be specified.
In a HAVING clause, aggregate expressions can also be used.
Any internal table whose row type corresponds to that of a ranges table can be specified for the ranges table range_tab.
BEGIN_SECTION VERSION 5 OUT This includes, in particular, selection tables.
END_SECTION VERSION 5 OUT
The ranges table is evaluated in the same way as in comparison expressions, with the difference that any comparisons using the operators CP and NP are transformed into LIKE conditions for which the AB-SQL escape character # is defined. The pattern after CP or NP is transformed to a pattern for LIKE as follows:
If the AB-SQL wildcard characters % and _ are contained in the pattern, the # escape character is inserted in front of these characters.
Any wildcard characters * and + that are not prefixed with the escape character # are transformed to the AB-SQL wildcard characters % and _.
Any # escape characters that do not prefix themselves or the AB-SQL wildcard characters % and _ are removed.
If the ranges table is initial, the expression IN range_tab is always true. This overrides the general rule that the result of a relational expression is unknown if an operand has the null value.
The content of the columns LOW and HIGH in the ranges table must match the data type of the operand in accordance with the rules for lossless assignments.
BEGIN_SECTION VERSION 5 OUT This is checked by the strict modes of the syntax check from ABAP_RELEASE ABAP_740_SP08 and can raise an exception.
END_SECTION VERSION 5 OUT



Latest notes:

LIKE conditions resulting from CP or NP are case-sensitive, which is not the case in ABAP comparison expressions.
If no conditions are specified apart from IN range_tab, all rows of the data source are selected if the ranges table is initial.
The conditions specified in the ranges table are passed by the database interface to the database as SQL statement input values. The maximum number of input values depends on the database system and is usually between 2000 and 10000. If the maximum number is exceeded an exception of the class CX_SY_OPEN_SQL_DB is raised.
For an initial ranges table, no condition is passed to the database and therefore, the result is always true.
If the ranges table contains invalid values, an uncatchable exception is raised.
No host expression can be specified on the right side whose result represents a ranges table.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
A ranges table is filled as follows and 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*
When used in sql_cond, this generates the following combination of relational expressions: ... ( 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 '#' ...
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX
Use of a selection table defined for a selection screen with SELECT-OPTIONS in a WHERE clause.
ABEXA 01409
ABAP_EXAMPLE_END

ABAP_EXAMPLE_V5
Use of a ranges table in a WHERE clause.
ABEXA 01738
ABAP_EXAMPLE_END