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 - literal

Other versions: 7.31 | 7.40 | 7.54

Syntax


... { [+|-]n[n[n[...]]] 
    | 'c[c[c[...]]]' | <i class="bn">[</i>c<i class="bn">[</i>c<i class="bn">[</i>c<i class="bn">[</i>...<i class="bn">]</i><i class="bn">]</i><i class="bn">]</i><i class="bn">]</i> } ...

Effect

Appropriate ABAP literals can also be specified in reading positions of ABAP SQL statements where host variables are possible. Literals are usually handled like host variables. Literals are not, however, prefixed with the escape character @. The literal operator can be used in ABAP SQL. The following applies, depending on the operand position:

  • If a literal is specified in an operand position in which it is handled like an elementary SQL expression, the corresponding rules apply and the literal is mapped to a dictionary type and evaluated accordingly on the database.
  • If a literal is specified in an operand position in which it is not handled like an SQL expression, a lossless conversion to the data type required in the operand position must be possible. Non-matching literals produce, depending on the syntax check mode, syntax warnings or syntax errors.


Notes

  • String literals are possible only in operand positions in which literals cannot be handled as elementary SQL expressions.

  • In some operand positions in which literals are allowed and host expressions are prohibited, a literal an still be specified with the syntax @( literal ) and is handled as a literal and not as an expression.

Example

Reads data from the database table SPFLI using ABAP SQL. The rows in question are specified in the WHERE condition. After UP TO, a numeric literal specifies the maximum number of rows to read.

SELECT FROM spfli 
       FIELDS 'Lufthansa' AS name, 
              cityfrom, 
              cityto 
       WHERE carrid = 'LH'  AND 
             countryfr = 'DE' 
       INTO TABLE @DATA(wa) 
       UP TO 10 ROWS.