What does it do? These variants for specifying the memory area mem_area>> of the statement ASSIGN>> dynamically are used to dynamically access data objects. In an inline declaration of the field symbol using FIELD-SYMBOL(<(><)>)>>, its typing is performed with the generic type data>. In these variants, the statement ASSIGN> sets the return code sy-subrc>. If the assignment is successful, sy-subrc> is set to 0, otherwise to 4. In these variants, no exception occurs in case of an unsuccessful assignment. If the assignment is not successful, the state of the field symbol depends on the addition ELSE UNASSIGN>>:
If ELSE UNASSIGN> is not specified, the field symbol keeps its previous state.
If ELSE UNASSIGN> is specified, no memory area is assigned to the field symbol. The field symbol has the state unassigned after the ASSIGN> statement.
Latest notes: If ELSE UNASSIGN> is not specified, it is not sufficient to evaluate the predicate expression > <(><)> IS ASSIGNED>> but sy-subrc> must be checked. If ELSE UNASSIGN> is specified, the predicate expression as well as sy-subrc> can be evaluated. NON_V5_HINTS ABAP_HINT_END
ABAP Alternative 1 ... (dobj_name)> BEGIN_SECTION ID ASSIGN-DYNAMIC
What does it do? In this dynamic variant of mem_area>, the memory area is not specified directly>, but as content of a character-like data object (dobj_name)> in parentheses. The following can be specified for dobj_name>:
Literal or constants If the data object dobj_name> is specified as a character literal or as a constant, it can be evaluated statically, and the specified data object is recognized as the used object.
Variable If the data object dobj_name> is specified as a variable, it is specified only dynamically, and the content is not evaluated statically. When the statement is executed, dobj_name> is not evaluated until runtime in both cases. The name in dobj_name> is structured in exactly the same way as if specified directly: When executing the statement, the content of dobj_name> must be the name of a data object which may contain offsets and lengths, structure component selectors, and other component selectors> for assigning structure components, attributes in classes or attributes in objects. The content of dobj_name> does not have to be in uppercase letters. dobj_name> can contain a chain of names consisting of component selectors. For an individual name or if the first name is followed by an object component selector (->>), the specified data object is searched for according to the following hierarchy: If the statement is located in a procedure >, the system searches for the local data objects of the procedure. If the statement is located in a method>, the system searches in the visible attributes of a class in the method. In instance methods, this means a search of the static type> of me> (special case of cref->(attr_name)> in dynamic_access>>). The system searches in the global data of the current program. BEGIN_SECTION VERSION 5 OUT The system searches in the interface work areas of the main program> of the current program group declared using TABLES>. END_SECTION VERSION 5 OUT If the statement is in an instance method>, the system searches in the dynamic type> of me> (special case of cref->(attr_name)> in dynamic_access>>). If the data object is found and the name is followed by an object component selector (->>), the search for the following names is continued from left to right, as described under dynamic_access>>. If the first name is followed by a class component selector (=> >), the specified class is searched for, as described under dynamic_access>>, and the search is then continued accordingly from left to right.