ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  ABAP SQL →  ABAP SQL - Reads →  SELECT clauses →  SELECT - INTO, APPENDING → 

SELECT - Assignment Rules

The following assignment rules apply to assignments of the result fields of the results set of a standalone SELECT, WITH, or FETCH statement to the target fields defined in the INTO clause.

Prerequisites

The following table shows the prerequisites for assigning individual columns of the results set to individual data objects - that is, for all forms of the SELECT statement, except when all columns in a work area wa are read with * and CORRESPONDING FIELDS is not specified at the same time. The table shows which data types of the result set can be assigned to which ABAP data types.

Data Type of Column in Result Set ABAP Data Type
CHAR, CLNT, CUKY, LANG, SSTRING, STRING, UNIT c, string
ACCP, NUMC c, n
LCHR c
RAW, RAWSTRING x, xstring
LRAW x
DF16_DEC decfloat16, decfloat34
DF16_RAW, DF16_SCL (obsolete) decfloat16
DF34_DEC, DF34_RAW, DF34_SCL (obsolete) decfloat34
CURR, DEC, INT1, INT2, INT4, INT8, PREC, QUAN (b, s), i, int8, p, f
FLTP f
DATS d
TIMS t

Notes

Rules

The following rules apply to the assignment procedure:

For assignments of LOBs to reference variables, see LOB Handles.

Example

The variable result1 is given the value 1. Any surplus decimal places are cut off. The built-in SQL function ROUND can be used to perform roundings like in conversions in ABAP. result2 is given the value 2.

DELETE FROM demo_expressions.
INSERT demo_expressions FROM @( VALUE #( id   = 'X'
                                         dec2 = '1.9999999999' ) ).

DATA result1 TYPE i.
SELECT SINGLE
       FROM demo_expressions
       FIELDS dec2
       WHERE id = 'X'
       INTO (@result1).

DATA result2 TYPE i.
SELECT SINGLE
       FROM demo_expressions
       FIELDS ROUND( dec2,0 ) AS dec2
       WHERE id = 'X'
       INTO (@result2).