SAP SQL OPERANDS



Get Example source ABAP code based on a different SAP table
  



AB_SQL - SQL Operands sql_elem

ABAP_SYNTAX
... col
$| literal $| @dobj $| @( expr ) ...

What does it do?
Specifies a column col, a literal literal, a host variable @dobj, or a host expression @( expr ) as an elementary SQL operand in an AB_SQL operand position.
These elementary operands can have the following properties:
They can be specified as elementary SQL expressions in all operand positions in which SQL expressions are possible.
They can also occur in specific operand positions in which no SQL expressions or restricted SQL expressions are possible.
To operand positions in which host variables are handled as SQL expressions, the associated rules for the expressions apply. The rules of the respective position apply in operand positions in which no SQL expressions are possible.
While the value of a column col or a typed literal is determined on the database, the values of untyped literals, host variables, and host expressions are passed from ABAP to the database system before the SQL statement is executed or copied from the database system after it is executed. The operand position determines how the value of such an ABAP object is handled:
An ABAP object specified as an elementary SQL expression in a read position is mapped to a dictionary type as described there, passed to the database with this type, and handled accordingly. The database rules apply.
In operand positions in which an ABAP object is not handled as an SQL expression, a conversion between the respective types takes place according to ABAP conversion rules if necessary. The mapping of ABAP Dictionary types to ABAP types is respected if necessary. If an untyped literal , a host variable, or a host expression is read, conversions are subject to the rules for lossless assignments. If the assignment cannot be lossless, an exception is raised. Literals and host constants produce syntax warnings or syntax errors
BEGIN_SECTION VERSION 5 OUT , depending on the syntax check mode
END_SECTION VERSION 5 OUT .



Latest notes:

Typed literals are always handled as elementary SQL expressions, while untyped literals can also be handled as host variables, depending on the operand position.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
SQL expressions are possible on the left side of the WHERE condition. The specified column carrid can be placed in parentheses as an elementary SQL expression. No general SQL expressions are possible on the right side of the condition. The literal CHAR`UA` as an elementary SQL expression can be used, but not be set in parentheses.
ABEXA 01279
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
In the first SELECT statement, the host variable @field is in an operand position in which it is not handled as an elementary SQL expression. Their content must comply with the rules for lossless assignments, which is not the case here. This is why an exception of the class CX_SY_OPEN_SQL_DATA_ERROR is raised. In the second SELECT statement, the same host variable is in an operand position in which it is evaluated as an elementary SQL expression and a mapping takes place to a dictionary type and the value is evaluated using this type on the database. No exception is raised in this case.
ABEXA 01280
ABAP_EXAMPLE_END