ABAP - Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Assignments → 

Assignment and Conversion Rules

When the value of a source object (source) is assigned to a destination object (destination), three cases can be distinguished with respect to the data type:

  1. source and destination are compatible, which means that all technical type attributes match. The content is copied from source to destination without being converted. For flat data objects and related character-like or byte-like structural areas, a copy of the source object is created down to the exact byte. In the case of deep data objects, a reference is created in the destination object and the actual byte-like content of the reference cannot be seen externally. When entire structures are assigned, the response in terms of alignment gaps is undefined. The binary content of an alignment gap in the destination structure can either be copied from the source structure or keep the original value.

  2. source and destination are not compatible, but can be converted. The content of source is converted in accordance with the conversion rules and then copied to destination. Two data types are convertible if a conversion rule exists for them. An exception is raised if the content of source cannot be handled in accordance with the conversion rules. After an exception, the content of destination is determined by the category of the data type. An assignment that requires a conversion is always slower than an assignment without conversion.

  3. If the data objects are not compatible or convertible, no assignment can take place. If the syntax check detects this situation, a syntax error is displayed. If it does not, an exception is raised when the program is executed.

The following sections describe the conversion rules. Conversion rules exist for:

The special assignment rules for reference variables are described in a separate section.

The conversion rules explained here generally apply to all assignments and all statements in which the content of data objects is changed. Exceptions to these rules are explained for each individual statement.

The conversion operator CONV can be used in many operand positions to perform a conversion of a source value to an explicitly specified target data type in accordance with the rules explained here. System classes are provided for special conversions of character sets and numeric formats.

Notes

Programming Guideline

Avoid unexpected conversion results



Continue
Conversion Rules for Elementary Data Objects
Conversion Rules for Structures
Conversion Rules for Internal Tables
Conversion Rules for Meshes
Conversion Rules for Enumerated Types
System Classes for Converting Character Sets and Number Formats
Conversions - Performance Notes