ABAP SQL - @( expr )
... @( expr ) ...
Specification of a host expression in a ABAP SQL statement.
Host expressions are
expr that can be specified in operand positions in ABAP SQL.
expr is a
general expression position. Any expressions or calls possible here, plus individual data objects, can be specified.
Host expressions can be specified as elementary SQL expressions in all operand positions in which SQL expressions are possible. They can also occur in the following read positions in which no SQL expressions are possible:
- Right sides of SQL conditions (except
- Actual parameters for input parameters of CDS views or CDS table functions.
- Right side of a
The relevant restrictions apply in operand positions in which host variables are handled like SQL expressions.
The host expressions of an ABAP SQL statement are evaluated from left to right and the results are passed to the database, like the content of host variables. Conversions of the result of a host expression to the data type required in the operand position must be possible and be lossless. The following additional restrictions apply:
- Host expressions cannot be used in dynamic tokens.
- In a host expression of a
SELECT list, it is not possible to derive a data type from the operand position for the character
#for a constructor expression.
- In the operand positions where host expressions can be specified, it is also always possible to specify host variables. The reverse does not apply.
- In some operand positions in which host expressions are forbidden, but
host variables are allowed, the syntax @( literal
@( dobj )can be used. It is handled as a literal or host variable rather than as an expression.
- When host expressions are specified, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.
Gets the right side of a comparison in a
WHERE condition using a
call in a host expression. Within the host expression, the instance operator
NEW is used here to create a temporary object.
CLASS cls DEFINITION. PUBLIC SECTION. METHODS get_url RETURNING VALUE(url) TYPE scarr-url. ENDCLASS. CLASS cls IMPLEMENTATION. METHOD get_url. ... ENDMETHOD. ENDCLASS. START-OF-SELECTION. SELECT FROM scarr FIELDS carrname WHERE url = @( NEW cls( )->get_url( ) ) INTO TABLE @DATA(itab).