Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing External Data →  ABAP Database Accesses →  Open SQL →  Open SQL - Read Accesses →  SELECT →  SELECT - INTO 

SELECT - Assignment Rules

Other versions: 7.31 | 7.40 | 7.54

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 results set can be assigned to which ABAP data types.

Data Type of Column in Results 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, PREC, QUAN (b, s), i, p, f
FLTP f
DATS d
TIMS t


Note

Fields of the types STRING and RAWSTRING (LOBs) from the results set can be assigned to reference variables for LOB handles as well as to strings. The static type of these reference variables must be one of the class system classes or one of the intf system interfaces which support streaming and locators for Open SQL.

Rules

The following rules apply to the assignment procedure:

  • If the target field is of data type c or x, the content of the result field is inserted into the target field, left-aligned. If the target field is too short, the result is truncated to the right. If the target field is too long, it is padded with blanks or hexadecimal 0 on the right.
  • If the target field is of data type string or xstring, the content of the result field is inserted into the target field, left-aligned. In result fields of the type STRING, trailing spaces are adopted. The target field has the same length as the result field.
  • If the target field is of data type n, the content of the result field is inserted into the target field, right-aligned. If necessary, it is padded with zeroes on the left. If the target field is too short, the result is truncated to the left.
  • If a result field of type CURR, DEC, QUAN (number BCD format) or a result field of type FLOAT is assigned to a target field with fewer decimal places, the excess decimal places are handled in one of two ways; they are either rounded or cut off. The handling of decimal places depends on the database system, the release and, if SAP buffering is used, the AS ABAP release. In other words, it is not always certain which handling method will be applied.
  • If the result field contains a null value, a type-specific initial value is assigned to the target field.

For the assignment of LOBs to reference variables, refer to Creating LOB Handles.