Skip to content

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

sql_exp - sql_elem

Other versions: 7.31 | 7.40 | 7.54


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


Elementary expression in ABAP SQL. An elementary SQL expression represents one of the following values:

  • Value from the database
The column col can be of any elementary data type from ABAP Dictionary, unless otherwise documented for an operand position.
  • Values of the ABAP program passed to the database system
The ABAP objects can have any non-generic elementary ABAP data type except string and xstring and the name of a host variable must be tagged with the escape character @. Literals are handled strictly according to type. This means that string literals are not allowed and only text field literals of the type c can be used as character literals. Empty text field literals cannot be specified. The value of a numeric literal must be in the value range of type i, which means it always has type i.

The result of an elementary SQL expression is the value of the specified object or the result of the specified expression. If a value from the database is specified, the data type is its dictionary type. When an ABAP object is specified, the ABAP type is mapped to a dictionary type as follows:

Numeric ABAP Type Dictionary Type
b, s, i, int8 INT1, INT2, INT4, INT8
p DEC with appropriate length and decimal places
decfloat16, decfloat34 DF16_RAW, DF34_RAW
Character-Like ABAP Type Dictionary Type
c CHAR with appropriate length
n NUMC with appropriate length
Byte-Like ABAP Type Dictionary Type
x RAW with appropriate length
ABAP Type for Date, Time, and Time Stamp Dictionary Type
utclong UTCLONG

Text field literals are handled as fields with the type CHAR and the appropriate length. Any closing blanks are respected. Like any number literal of an ABAP program, number literals are handled either as a field with the type INT4 or the type DEC, depending on the value in question. Text string literals are not allowed.

On the database, the value of an ABAP object as an elementary expression is handled by the rules of the database in accordance with the mapped type. This behavior is different from other operand positions of ABAP objects in ABAP SQL, where they are not handled as elementary expressions. In these operand positions, the content is converted to the target type in accordance with the rules for lossless assignments.


  • Columns, literals, host variables, and host expressions can also occur as elementary SQL operands in operand positions in which no SQL expressions are possible. Columns, literals, hosts variables, and host expressions can only be handled as SQL expressions in positions where SQL expressions are possible. For example, these are the only places where they can be given parentheses. In this case, the statement can only have lists separated by commas and host variables must be indicated by the escape character @.

  • If an elementary SQL expression consists of a host variable in the form of a field symbol or formal parameter, this expression must be typed in full.

  • Literals, host variables, and host expressions as operands of other SQL expressions are evaluated before the ABAP SQL statement is sent to the database system. Specifying a host variable from a SELECT list after INTO in a SELECT loop does not mean that a different value is used in each loop pass.

  • The fact that literals, host variables, and host expressions are mapped to specific dictionary types as operands of SQL expressions, whereas other operand positions permit conversions to different target types, is particularly significant for relational expressions in which the comparability of dictionary types is important.

  • An elementary expression can always be evaluated in the table buffer. If an elementary expression is specified, table buffering is not bypassed.

  • If a host expression is used as an argument of another SQL expression, the syntax check is performed in a strict mode from Release 7.50, which handles the statement more strictly than the regular syntax check.


The SELECT list of the second SELECT statement contains all possible elementary SQL expressions.

DATA carrid TYPE scarr-carrid VALUE 'LH'. 
cl_demo_input=>request( CHANGING field = carrid ). 

       FIELDS carrid, carrname 
       INTO TABLE @DATA(carriers). 

       FROM spfli 
       FIELDS '*' AS mark, 
              @carrid AS id, 
              @( carriers[ carrid = carrid ]-carrname ) AS carrier, 
       WHERE carrid = @carrid 
       INTO @DATA(result). 

cl_demo_output=>display( result ).

Executable Example

Constant in the SELECT List


SQL Expressions, Constant in SELECT List