What does it do? These variants for specifying the memory area mem_area>> of the statement ASSIGN>> dynamically are designed especially for dynamic access to attributes of classes or interfaces (Dynamic Access). The same syntax as alternatives 1 and 2 is also possible for components of structures>. 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. If the assignment is not successful, sy-subrc> is set to 4. In these variants, no exception occurs in case of an unsuccessful assignment. If sy-subrc> is set to 4, 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:
Field symbols to which instance attributes or parts of instance attributes are assigned have a memory-preserving effect on the associated object.
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 ... cref->(attr_name)> BEGIN_SECTION ID ASSIGN-DYNAMIC-OREF
What does it do? This form is possible for all visible attributes of objects. cref > can be any class reference variable> that points to an object that contains the attribute specified in a character-like field attr_name>. The attribute is searched for first in the static type> of cref> and then in the dynamic type >. The attribute name does not have to be in uppercase letters. It can contain offsets/lengths, structure component selectors, object component selectors, and class component selectors, in order to assign parts of the attribute or referenced objects of the attribute. Unlike all other operand positions, where an object reference that does not point to an object raises an exception, no exception occurs in the statement ASSIGN> and sy-subrc> is set to 4. BEGIN_SECTION SAP_INTERNAL_HINT The exception is either the uncatchable OBJECTS_OBJREF_NOT_ASSIGNED > or the catchable CX_SY_ASSIGN_ILLEGAL_COMPONENT>. The latter is raised for a dynamic target>. END_SECTION SAP_INTERNAL_HINT