Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  ABAP SQL →  ABAP SQL - Operands and Expressions →  ABAP SQL - SQL Operands sql_elem 

ABAP SQL - @( expr )

Other versions: 7.31 | 7.40 | 7.54

Syntax


... @( expr ) ...

Effect

Specification of a host expression in a ABAP SQL statement. Host expressions are ABAP expressions 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:

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.


Notes

  • 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 literals and host variables are allowed, the syntax @( literal ) and @( 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.

Example

Gets the right side of a comparison in a WHERE condition using a functional method 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). 

Executable Examples

Continue

Host Expressions, Use in the WHERE Condition