SAP ASSIGN LOCAL COPY ABAP Statements



Get Example source ABAP code based on a different SAP table
  


ID ASSIGN-COPY
• LOCAL COPY OF ASSIGN - obsolete
• INITIAL ASSIGN LOCAL COPY OF (obsolete)
• INITIAL LINE OF ASSIGN LOCAL COPY OF (obsolete)
• TO ASSIGN LOCAL COPY OF (obsolete)

ASSIGN LOCAL COPY
Short Reference

ABAP_SYNTAX_OBS
ASSIGN LOCAL COPY
OF ${ ${$[INITIAL$] mem_area$}
$| ${INITIAL LINE OF ${itab$|(itab_name)$}$}
$| ${MAIN TABLE FIELD (name)$} $}
TO <(><)> casting_spec.

ABAP Addition
1 ... mem_area
2 ... MAIN TABLE FIELD (name)
3 ... casting_spec

What does it do?
Obsolete creation of a local data object. This variant of the ASSIGN statement is only possible in subroutines and function modules. The field symbol <(><)> must be declared locally in the procedure.
Like the regular statement ASSIGN, the statement ASSIGN LOCAL COPY assigns a memory area mem_area to the field symbol <(><)>. Unlike the regular 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 handled as follows:
The size of the memory area of the new data object depends either on the specification in mem_area or the row type of an internal table if LINE OF is specified. The internal table can be specified directly as itab or as the content of a flat character-like field itab_name.
The data type with which the new data object is handled depends, as when using the regular ASSIGN on the data in casting_spec.
The initial content of the new data object is copied from the memory area specified in mem_area when specifying mem_area without the addition INITIAL. Otherwise it is initialized according to the type.
The restriction of the memory area range_spec , which can occur in the regular ASSIGN statement implicitly and explicitly, occurs only implicitly in accordance with the rules that also apply to the regular ASSIGN.



Latest notes:

The creation of a local data object using the statement ASSIGN LOCAL COPY is replaced by the statement CREATE DATA with subsequent dereferencing in the regular ASSIGN statement.
The addition ELSE UNASSIGN cannot be used in this obsolete variant of the ASSIGN statement.
ABAP_HINT_END

ABAP Addition
Syntax of mem_area
... ${ dobj$[+off$]$[(len)$]
$| (name)
$| oref->(attr_name)
$| ${class$|(class_name)$}=>${attr$|(attr_name)$}
$| dref->* $} ...

What does it do?
The specifications in mem_area are a subset of the specifications in the regular ASSIGN statement and have the same function except for the following restrictions:
If the addition INITIAL is used before mem_area, the data object name must be character-like and flat .
If the addition INITIAL is used before mem_area, the data object dref cannot be typed generically when using the dereferencing operator ->*.
• MAIN TABLE FIELD ASSIGN LOCAL COPY OF - internal

ABAP Addition