What does it do? These variants for specifying the memory area mem_area>> of the statement ASSIGN>> exploit the fact that the operand position after ASSIGN> is a result position> in which writable expressions> can be specified.
Latest notes:
Writable expressions can be specified for the memory area but no other expressions, because only writable expressions can have a non-temporary result. Assigning a temporary data object to a field symbol would not make sense.
Writable expressions cannot be specified dynamically in a data object name>>. NON_V5_HINTS ABAP_HINT_END
ABAP Alternative 1 ... NEW class( ... )->attr$|(attr_name)>
What does it do? This variant for specifying the memory area mem_area>> of the statement ASSIGN>> assigns an attribute of an instance of class class> to a field symbol. The instance of the class is created inline with the constructor expression> NEW class( ... )>>. The object component selector ->> following the constructor expression selects the attribute. The attribute can be specified statically as attr> or dynamically as the content of a character-like data object attr_name> in parentheses.
For static specification attr>, the same rules apply as to statically specifying> the memory area, but no offsets/lengths can be specified and sy-subrc> is not set by the ASSIGN> statement itself.
For dynamic specification, the rules of a dynamic target> behind the object component selector apply. In this variant, the return code sy-subrc> is not set by the statement ASSIGN> itself, but by the constructor expression. The instance operator NEW> sets the return code sy-subrc> to 0, if the object is created successfully. If the attribute specified dynamically in attr_name> is not found, an exception of class CX_SY_ASSIGN_ILLEGAL_COMPONENT> is raised. An assignment of the constructor operator NEW> is either successful or leads to an exception and the addition ELSE UNASSIGN > cannot be used. In case of an exception, an existing field symbol keeps it previous state.