ASSIGN
Short Reference
ABAP Syntax ASSIGN mem_area TO
fs casting_spec
range_spec .
What does it do? This statement assigns the memory area specified using
mem_area to the field symbol
fs . A data object or a memory area calculated from the address
of a data object can be assigned. After the assignment, the field symbol
refers to the assigned memory area and can be used in operand positions.
When used in a statement, it behaves like a dereferenced data reference,
meaning that the statement works with the content of the memory area.
The following can be specified for fs :
An existing field symbol with appropriate typing.
An inline declaration FIELD-SYMBOL(
fs ) . The typing depends on the
mem_area specified.
The data type with which the assigned memory area is handled depends
on what is specified in casting_spec .
Either an explicit casting can be
performed or the field symbol uses the data type of the data object
specified in the assignment. In both cases, the data type used must
match the typing
of the field symbol. A field symbol to which a memory area is
assigned, has this data type after the assignment and behaves like a
data object of this type.
The assigned memory area mem_area must be at least as long as
the data type specified in casting_spec and must have at least
the same alignment . If the data type
determined in casting_spec is deep , the
deep components with their type and position must appear in the assigned
memory area exactly like this.
The information in range_spec is used
to define the memory area that can be assigned to the field symbol.
System Fields
The return value is set only for the
dynamic variants and the
table expression variant of
mem_area . If the constructor operator
NEW is used as a writable
expression , this operator sets the return value.
sy-subrc Meaning
0Assignment completed.
4Assignment not completed.
8A table expression was not
assigned.
If a dynamic assignment or assignment of a table expression could not
be performed, the field symbol keeps its previous state. If the static
assignment could not be performed, a memory is not assigned to the field
symbol after the statement ASSIGN and the assignment can be
checked with the predicate
expression fs IS ASSIGNED .
If an assignment were to produce illegal memory accesses, an exception
is raised in the case of both static and dynamic ASSIGN
statements.
Latest notes: If field symbols are set using ASSIGN , permission
to access the assigned data object is only checked at the position of
the statement. The field symbol can then be passed on as required and
used to access the assigned data object in any position. To prevent
access to private and read-only attributes using field symbols outside
classes, field symbols for these attributes should not be published
externally. A constant or read-only input parameter, however, can never
be made modifiable by passing a field symbol.
One obsolete form of the statement MOVE is
MOVE PERCENTAGE .
Documentation extract taken from SAP system, © Copyright SAP AG. All rights reserved