SAP® Documentation

Single view

ABAPASSIGN_LOCAL_COPY - ASSIGN LOCAL COPY

rdisp/max_wprun_time - Maximum work process run time   General Material Data  
This documentation is copyright by SAP AG.
SAP E-Book

ASSIGN LOCAL COPY

Short Reference



Obsolete Syntax

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

Additions

1. ... mem_area

2. ... MAIN TABLE FIELD (name)

3. ... casting_spec

Effect

Obsolete creation of a local data object. This variant of the ASSIGN statement can only be used in subroutines and function modules. The field symbol<fs> 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 <fs>. 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 treated as follows:

  • The size of the memory area of the new data object conforms to either the data in mem_area or the line typeof 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 to be handled conforms to the data in casting_spec as is the case when using the regular ASSIGN.
  • 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 type.

Limitation 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 normal ASSIGN.

Note

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.

Addition 1

... mem_area

Syntax of mem_area

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


Effect

The specifications in mem_area are a subset of the specifications in the regular ASSIGN statement. They 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 ->*.


Addition 2

... MAIN TABLE FIELD (name)

This addition is for internal use only.
It cannot be used in application programs


Effect

This addition is a special form of the specified memory area mem_area that can only be used in this variant of the ASSIGN statement. It has the same function as the obsolete TABLE FIELD (name) in a regular ASSIGN with the exception that the search area is restricted to the current main program group.

Addition 3

... casting_spec

Effect

If specified, casting_spec is the same as a regular 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.

Example

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.
  cl_demo_output=>write_data( <l_dobj> ).
  cl_demo_output=>display_data( g_dobj ).
ENDFORM.

The following subroutine shows how the same functions can be universally implemented with a data reference.

DATA g_dobj TYPE i.
...
CLEAR g_dobj.
PERFORM subroutine2.
...
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.
  cl_demo_output=>write_data( <l_dobj> ).
  cl_demo_output=>display_data( g_dobj ).
ENDFORM.






SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   CPI1466 during Backup  
This documentation is copyright by SAP AG.

Length: 8413 Date: 20200125 Time: 102247     sap01-206 ( 90 ms )

Our Service

Looking for Support? Questions?

The

Consolut

Callback-Service

Leave us your contact details and we will call you back. Panels marked with * are mandatory.