ABAPASSIGN_MEM_AREA - ASSIGN MEM AREA
PERFORM Short Reference General Data in Customer MasterThis documentation is copyright by SAP AG.
ASSIGN - mem_area
Syntax
... { dobj[+off][(len)] }
| { dynamic_dobj }
| { dynamic_access } ... .
Alternatives:
Static Specification
1. ... dobj[+off][(len)]
Dynamic Specifications
2. ... dynamic_dobj
3. ... dynamic_access
Effect
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_dobjare used for general dynamic access to data objects; the variants dynamic_accessare 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 dynamicvariants, the ASSIGN statement sets the return code sy-subrc, which is not the case with static variants.
Note
In an internal table with a header line, either the header line or thetablebody can be assigned to a field symbol. In the ASSIGN statement, the name of an internaltable with a header line addresses the header line. To address the table body, [] must be appendedto 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.
Alternative 1
... dobj[+off][(len)]
Effect
The memory area is specified by a data object dobjj specified in accordance with the rules described in the sectionData Objectsin the Operand Positions. In particular, dobj itself can be specified by a field symbol. If you have an offset/length specification, the data type dobj here must not be string or xstring.
- If no offset/length specification is made, the assigned memory area is the same as the memory area ofthe 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 dataobject and the offset/length specifications. Memory outside of the field limits for dobj canbe 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 RANGEaddition is used, no offset off can be specified without the length len inUnicode programs. If the name of a field symbol is specified for dobj, its data type must beflatand elementary in Unicode programs - 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 ASSIGNstatement. The return code sy-subrc is not set for static variants. Instead, the logical expression<fs> IS ASSIGNED can be evaluated.
Notes
- 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.
Example
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'.
FIELD-SYMBOLS <char> TYPE c.
DATA off TYPE i.
DO 10 TIMES.
off = sy-index - 1.
ASSIGN text+off(1) TO <char>.
WRITE / <char>.
ENDDO.
TXBHW - Original Tax Base Amount in Local Currency BAL_S_LOG - Application Log: Log header data
This documentation is copyright by SAP AG.
Length: 6283 Date: 20120518 Time: 192642 triton ( 242 ms )






