ABAP - Keyword Documentation →  ABAP - Reference →  Processing External Data →  ABAP Database Accesses →  Open SQL →  Open SQL - Operands → 

Open SQL - Host Variables

Syntax

... @dobj ...

Effect

Host variables are global or local variables (usually variables) dobj declared in the ABAP program that are used in operand positions of Open SQL statements. Instead of the data object itself, a field symbol to which the data object is assigned can be specified. Dereferenced data reference variables can also be specified.

To identify a host variable, the names of named data objects or field symbols should always be directly prefixed by the escape character @. The escape character can only be used in programs, in which the program property fixed point arithmetic is activated. When the escape character is used, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.

The content of host variables in reading positions is passed to the database system together with the SQL statement before it is executed. The content of host variables in writing positions is taken from the database system after the SQL statement is ended.

Notes

Example

Specifies various host variables; the escape character @ is always used.

DATA carrid TYPE spfli-carrid.
cl_demo_input=>request( CHANGING field = carrid ).

DATA: BEGIN OF result,
         carrid TYPE sflight-carrid,
         connid TYPE sflight-connid,
       END OF result.
SELECT carrid, connid
       FROM sflight
       INTO CORRESPONDING FIELDS OF @result
       WHERE carrid = @carrid.
  ...
ENDSELECT.

FIELD-SYMBOLS <result> LIKE result.
SELECT carrid, connid
       FROM sflight
       INTO CORRESPONDING FIELDS OF @<result>
       WHERE carrid = @carrid.
  ...
ENDSELECT.

DATA dref LIKE REF TO result.
SELECT carrid, connid
       FROM sflight
       INTO CORRESPONDING FIELDS OF @dref->*
       WHERE carrid = @carrid.
  ...
ENDSELECT.