SAP ABAP SQL STMT LOGEXP



Get Example source ABAP code based on a different SAP table
  



ABAP_SQLCOND - rel_exp for Statements
Short Reference

ABAP_SYNTAX
... ${ ${operand1 ${=$|EQ$|<(> <<)>>$|NE$|>$|GT$| < $|LT$|>=$|GE$| < =$|LE$}
${ operand2
$| ${ $[ALL$|ANY$|SOME$] ( SELECT subquery_clauses $[ UNION$|INTERSECT$|EXCEPT ...$] )$} $}$}
$| ${operand $[NOT$] BETWEEN operand1 AND operand2$}
$| ${operand1 $[NOT$] LIKE operand2 $[ESCAPE esc$]$}
$| ${operand IS $[NOT$] NULL$}
$| ${operand IS $[NOT$] INITIAL$}
$| ${EXISTS ( SELECT subquery_clauses $[ UNION$|INTERSECT$|EXCEPT ...$] )$}
$| ${operand $[NOT$] IN (operand1, operand2 ...)$}
$| ${operand $[NOT$] IN ( SELECT subquery_clauses $[ UNION$|INTERSECT$|EXCEPT ...$] )$}
$| ${( operand1, operand2, ... ) IN ( ( operand11, operand21 ... ),
( operand12, operand22 ... ), ... )$}
$| ${operand $[NOT$] IN @range_tab $}
$| ${(cond_syntax)$} $} ...

What does it do?
Relational expression in a condition of an AB-SQL statement. Logical expressions sql_cond can be formed from the relational expressions shown here for the following conditions:
Read accesses
WHERE clause of a query
HAVING clause of a query
ON condition of a join expression
Modifying accesses
WHERE condition of the statement UPDATE
WHERE condition of the statement DELETE
Possible operands of a relational expression are elementary SQL operands and SQL expressions. The kind of expression and where it is used determine which operands can be used and where. The following principles apply:
On the right side of relational expressions, elementary SQL expressions, cast expressions, and built-in SQL functions can be used. No other SQL expressions are possible. Typed literals are handled as elementary SQL expressions, while untyped literals are handled like host variables.
Aggregate expressions can only be used as operands in the HAVING clause of a query, but also on the right side.
Window expressions cannot be used.
Operands of the type STRING, RAWSTRING, LCHR, LRAW, or GEOM_EWKB cannot be used. One exception is the expression IS $[NOT$] NULL, which can also evaluate LOBs and geodata types.
A relational expression rel_exp is either
true
false, or
unknown.
The expression is unknown if one of the operands involved contains the null value and is evaluated with a comparison other than IS NULL. The result of joins of relational expressions with unknown results is described under AND, OR, NOT.
In an SQL condition of a statement, the client column of a client-dependent data source of a query or of the target of a write statement cannot be used as an operand due to implicit client handling.
BEGIN_SECTION VERSION 5 OUT This is checked completely in the strict modes of the syntax check from ABAP_RELEASE ABAP_740_SP05 .
END_SECTION VERSION 5 OUT



Latest notes:

In comparisons between values determined on the database, it is essential that only operands of the same type and the same length are used. This avoids platform-dependent conversions from taking place.
The AB-SQL statement bypasses table buffering in the following cases:
If expressions other than the SQL expressions that can be evaluated in the table buffer are used on the left side of a relational expression.
If items other than host variables or host expressions are specified on the right side of a relational expression or are used to identify a single record or a generically buffered area. In other conditions not used for identifications, columns can also be specified in comparisons or when BETWEEN is used. This applies in cases where neither numeric operand has the type DF16_DEC or DF34_DEC, both operands are character-like, or both operands have the type RAW with the same length.
A client column can be used as an operand only if implicit client handling is disabled using the obsolete addition CLIENT SPECIFIED for the query or the write statement.
That the result of a check is unknown if one of the operands has the null value, is especially true for the null expression NULL that contains the null value by definition.
Single relational expressions that are unknown can be handled similarly to expressions that are false in the sense that they are not true. Caution is needed when using AND, OR, NOT. For example, an unknown expression cannot be made true by using NOT.
The rule that the result of an relational expression is unknown if an operand contains the null value is overridden by an initial ranges table in the expression IN range_tab. It also has no effect if an empty internal table is used for FOR ALL ENTRIES because then the entire WHERE condition is ignored.
NON_V5_HINTS
If in dynamic conditions alias names defined with AS or joins are used, a client column can be accessed outside the strict modes of the syntax check in WHERE conditions and ON conditions, without implicit client handling being disabled using CLIENT SPECIFIED. In this case, there are two conditions for the client column: the implicit condition of the automatic client handler for the current client and the explicitly specified condition. If the current client is not specified in the explicitly specified condition, no rows are selected.
When SQL expressions occur on the left side of a relational expression, the syntax check is performed in a ABAP_STRICT_760 strict mode / , which handles the statement more strictly than the regular syntax check.
ABAP_HINT_END