Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Assignments →  Setting References →  ASSIGN 

ASSIGN - mem_area

Short Reference

Other versions: 7.31 | 7.40 | 7.54


... { dobj[+off][(len)] } 
  | { dynamic_dobj }
  | { dynamic_access } ... .


Static SpecificationDynamic Specifications


You use mem_area to specify the memory area that is assigned to the field symbol.

The first variant is a static variant, whereas the other variants are dynamic. The variants dynamic_dobj are used for general dynamic access to data objects; the variants dynamic_access are used for dynamic access to the attributes of classes.

Static and dynamic variants differ in the way the system behaves after a successful assignment: In dynamic variants, the ASSIGN statement sets the return code sy-subrc, which is not the case with static variants.


  • In an internal table with a header line, either the header line or the table body can be assigned to a field symbol. In the ASSIGN statement, the name of an internal table with a header line addresses the header line. To address the table body, [] must be appended to the name in the usual way. A field symbol to which a table body is assigned behaves in the same way in operand positions as a table without a header line.
  • Field symbols to which data objects or parts of data objects are assigned in the heap are memory-preserving, like heap references.

Alternative 1

... dobj[+off][(len)]


The memory area is specified by a data object dobjj specified in accordance with the rules described in the section Data Objects in the Operand Positions. In particular, dobj itself can be specified by a field symbol. In an offset/length specification, the data type of dobj must not be string orxstring, ensuring that len cannot be less than or equal to zero.

  • If no offset/length specification is made, the assigned memory area is the same as the memory area of the data object. The entire data object dobj is assigned to the field symbol, and statements that contain the field symbol in operand positions work with the data object.
  • If an offset/length is specified, the memory area is determined from the memory address of the data object and the offset/length specifications. Memory outside of the field limits for dobj can be addressed. The addressable memory is based on the specification range_spec. If an offset off is specified without a length len, the length of the data object dobj is used implicitly for len.

    If the name of a data object is specified for dobj and if no explicit RANGE addition is used, no offset off can be specified without the length len. If the name of a field symbol is specified for dobj, its data type must be flat and elementary whenever an offset off is specified without length len.
  • If a field symbol is specified for dobj, to which a memory area is already assigned, the content of the offset length can be negative, as long as the area specified in range_spec is not exited.

If the assignment is not successful, no memory area is assigned to the field symbol after the ASSIGN statement. The return code sy-subrc is not set for static variants. Instead, the logical expression <fs> IS ASSIGNED can be evaluated.


  • Ensure that you do not inadvertently evaluate the system field sy-subrc after the static variant. The value of the system field in this case is always the same as it was before the ASSIGN statement was executed and therefore does not indicate whether the statement was successful.
  • Even the static variant is dynamic in the sense that the offset and length specifications may be dynamic. Dynamic offset/length specifications do not, however, result in the system field sy-subrc being set.


Assignment of the memory area of the individual characters of a data object text to a field symbol <char>.

DATA text TYPE c LENGTH 10 VALUE '0123456789'. 


DATA off TYPE i. 

  off = sy-index - 1. 
  ASSIGN text+off(1) TO <char>. 
  WRITE / <char>. 


ASSIGN - dynamic_dobj

ASSIGN - dynamic_access