ASSIGN LOCAL COPY
OF { {[INITIAL] mem_area}
| {INITIAL LINE OF {itab|(itab_name)}}
| {MAIN TABLE FIELD (name)} }
TO <fs> casting_spec.
1. ... mem_area
2. ... MAIN TABLE FIELD (name)
3. ... casting_spec
Obsolete creation of a local data object. This variant of the ASSIGN statement can only be used in subroutines and funktion modules. The field symbol <fs> must be declared locally in the procedure.
Like the normal statement ASSIGN, the statement ASSIGN LOCAL COPY assigns a memory area mem_area to the field symbol <fs>. In contrast to the normal statement ASSIGN, the field symbol does not reference the memory area specified in mem_area after the successful assignment. Instead, an anonymous data object is created in the local data area of the procedure. After the successful execution of the statement, the field symbol points to the new data object. The new data object is treated as follows:
Limitiation of the memory area range_spec,
which can occur in the normal ASSIGN statement implicitly
and - as of release 6.10 - explicitly, occurs only implicitly in accordance with the rules that also apply to the normal ASSIGN.
As of release 4.6, the creation of a local data object with the statement
ASSIGN LOCAL COPY is replaced with the statement CREATE
DATA with subsequent deferencing in the normal ASSIGN statement.
... mem_area
Syntax von mem_area
... { dobj[+off][(len)]
| (name)
| oref->(attr_name)
| {class|(class_name)}=>{attr|(attr_name)}
| dref->* } ...
The specifications in mem_area are a subset of the specifications in the normal ASSIGN statement. They have the same function except for the following restrictions:
... MAIN TABLE FIELD (name)
This addition is for internal use only.
It cannot be used in application programs
This addition is a special form of the specification of the memory area
mem_area that can only be used in this variant ofthe ASSIGN
statement. It has the same function as the statement
TABLE FIELD (name) of the normal ASSIGN with the exception that the search area is restricted to the current
main program group.
... casting_spec
The specification of casting_spec corresponds to that
of the normal ASSIGN
with the limitation that if the addition INITIAL is used
before mem_area and an internal tables is specified, no
explicit specifications can be made. This means, the field symbol copies the data type of the data object in mem_area or the line type of the internal table.
Prior to release 4.6, a typical use of the statement ASSIGN LOCAL COPY was the creation of a local copy of a global data object.
DATA g_dobj TYPE i.
...
CLEAR g_dobj.
PERFORM subroutine1.
...
FORM subroutine1.
FIELD-SYMBOLS <l_dobj> TYPE ANY.
ASSIGN LOCAL COPY OF g_dobj TO <l_dobj>.
<l_dobj> = <l_dobj> + 1.
WRITE: / g_dobj, <l_dobj>.
ENDFORM.
The following subroutine shows how the same functions can be universally implemented with a data reference as of release 4.6.
FORM subroutine2.
DATA dref TYPE REF TO data.
FIELD-SYMBOLS <l_dobj> TYPE ANY.
CREATE DATA dref LIKE g_dobj.
ASSIGN dref->* TO <l_dobj>.
<l_dobj> = g_dobj.
<l_dobj> = <l_dobj> + 1.
WRITE: / g_dobj, <l_dobj>.
ENDFORM.