SAP SQL EXPR ABAP Statements
Get Example source ABAP code based on a different SAP table
AB_SQL - SQL Expressions sql_exp> ABAP_SYNTAX ... sql_elem>
$| sql_func>
$| sql_arith>
$| sql_cast>
$| sql_string>
$| sql_case>
$| sql_agg>
$| sql_win>
$| sql_null> ...>
What does it do?
SQL expressions are expressions that generally can be specified in the following positions of AB-SQL statements:
As columns specified> in the SELECT> list>
As arguments of certain aggregate expressions > in the SELECT> list> and in the HAVING> clause>
As operands of SQL conditions>:
On the left side of an SQL condition for statements>
On the left and right side of an SQL condition for expressions>
As a grouping criterion after GROUP BY>>
As a sort criterion after ORDER BY>>
As a window criterion after PARTITION BY>>
Some expressions, such as CAST> expressions, can also be specified at other positions and built-in functions can be specified on the right side of SQL conditions for statements. This is documented for the respective positions.
SQL expressions are passed to the database system, executed there, and the result is passed to the AS ABAP if requested.
In general, the operands of SQL expressions can also be SQL expressions whose result must have a suitable data type. There are restrictions to individual operand positions, which are described for these.
The following SQL expressions exist:
Elementary SQL expressions>
Calls of built-in SQL functions>
Arithmetic expressions>
Cast expressions>
String expressions>
Case distinctions>
Aggregate expressions>
Window expressions>
Null expressions>
Every expression can be enclosed in parentheses>. The result of an expression is used in the AB-SQL statement in accordance with the operand position, with the data type in nested expressions based on the outermost expression.
Latest notes:
No alias names defined using AS>> can be used as operands of SQL expressions. This also means that none of the expressions used in a SELECT> list can be specified as operands using their alias names.
SQL expressions cannot currently be used together with the addition FOR ALL ENTRIES>>. An exception to this rule are individual columns and an individually specified aggregate expression COUNT( * )>.
Certain SQL expressions> can be calculated in the table buffer>. If the remaining SQL expressions are used, table buffering> is bypassed.
NON_V5_HINTS
When SQL expressions are used other than for individually specified columns or individually specified aggregate expressions, the syntax check is performed in a ABAP_STRICT_740_SP05 strict mode as of ABAP_RELEASE ABAP_740_SP05 / , which handles the statement more strictly than the regular syntax check. If other SQL expressions are specified along with aggregate expressions> or the addition GROUP BY>>, the syntax check is performed in ABAP_STRICT_740_SP08 strict mode as of ABAP_RELEASE ABAP_740_SP08 / . Using aggregate expressions> as operands of SQL expressions results in the ABAP_STRICT_774 strict mode as of ABAP_RELEASE ABAP_774 / .
ABAP_HINT_END
ABAP_EXAMPLE_VX5
Syntax example for specifying SQL expressions in different operand positions in a SELECT>> statement.
ABEXA 00684
ABAP_EXAMPLE_END
Return to menu