
Assignments of the content of a data object source to a data object target are made using the assignment operator =:
target = source.
If the type of the data object source does not match the type of target, and a conversion rule is defined between the data types, the system attempts to convert the content of source so that it matches the data type of target. If the content cannot be converted, an exception is raised. Conversion rules exist between:
All elementary ABAP types, except between d and t
Structures
Elementary data objects and structures
Internal tables
References can be assigned to references, if the type of source is the same as the type of target or more specific (known as an up cast). If this is not the case, the assignment operator ?= or the casting operator CAST( ... ) must be used to perform a down cast. The statement CLEAR is used to set a data object to its type-compatible initial value.
In assignments between structures, the components of the structure target can be assigned their values using the identically named components of a structure source:
MOVE-CORRESPONDING source TO target.
Here, all identically named components are found in both structures, source and target, and the content of these components in source assigned to the identically named components in target. Any further components in target are not affected.
Example
Assigns the predefined system field sy-datum to a date field date declared inline, which then contains the current date. Assigns this value to an integer field days while performing a conversion to the number of days since 01.01.0001.
DATA days TYPE i.
DATA(date) = sy-datum.
days = date.