Documentation View

We are hiring and constantly growing! Have a look through our vacancies to find the right role for you!

ABAPASSIGN_LOCAL_COPY - ASSIGN LOCAL COPY

ABAPASSIGN_LOCAL_COPY - ASSIGN LOCAL COPY

ROGBILLS - Synchronize billing plans   ABAP Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

ASSIGN LOCAL COPY

Short Reference



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 is only possible 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 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.

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 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 ->*.

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 specifying the memory area mem_area that is only possible in this variant of the ASSIGN statement. It has the same function as the obsolete TABLE FIELD (name) in a regular ASSIGN with the difference that the search range is restricted to the current main program group.

Addition 3

... casting_spec

Effect

Specifying casting_spec is the same as a regular ASSIGN with the restriction 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.

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






SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   PERFORM Short Reference  
This documentation is copyright by SAP AG.

Length: 6889 Date: 20221203 Time: 164118     sap01-206 ( 105 ms )