Ansicht
Dokumentation

ABAPASSIGN_MEM_AREA_DYNAMIC_ACCESS - ASSIGN MEM AREA DYNAMIC ACCESS

ABAPASSIGN_MEM_AREA_DYNAMIC_ACCESS - ASSIGN MEM AREA DYNAMIC ACCESS

PERFORM Short Reference   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.
SAP E-Book

ASSIGN, dynamic_access

Short Reference



... ${ cref->(attr_name) $}
  $| ${ iref->(attr_name) $}
  $| ${ (clif_name)=>(attr_name) $}
  $| ${ (clif_name)=>attr $}
  $| ${ clif=>(attr_name) $} ...

Alternatives:

2. ... cref->(attr_name)

3. ... iref->(attr_name)

4. ... (clif_name)=>(attr_name)

5. ... (clif_name)=>attr

6. ... clif=>(attr_name)

Effect

These alternatives 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(<fs>), 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. If the assignment is not successful, the field symbol keeps its previous state. It is therefore not sufficient to evaluate the predicate expression <fs> IS ASSIGNED and sy-subrc needs to be checked as well.

Note

Field symbols to which instance attributes or parts of instance attributes are assigned have a memory-preserving effect on the associated object.

Alternative 2

... cref->(attr_name)


Effect

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 system searches for the attribute 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.

Dynamic assignment of an object attribute of an object to a field symbol. The assignment is made via an object reference variable of the static type of the root class object, which can point to any object.

Alternative 3

... iref->(attr_name)


Effect

This form may be used for all visible attributes of objects. iref can be any interface reference variable that points to an object that contains the interface attribute specified in a character-like field attr_name. The search for this method takes place only in the static type of iref.

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.

Example

Dynamic assignment of an object attribute to a field symbol. The assignment is made via an interface reference variable.

Alternative 4

... (clif_name)=>(attr_name)


Alternative 5

... (clif_name)=>attr


Effect

These forms may be used for all visible static attributes. Classes and interfaces and also attributes can be specified dynamically in character-like fields clif_name or attr_name. The attribute attr can, however, also be specified directly. The system searches for the class or interface first and then the attribute.

The content of attr_name and clif_name does not have to be in uppercase letters. attr_name 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. Here, no offsets/lengths or object component selectors can be specified after a directly specified attribute attr.

Note

If a class of another program is specified in clif_name using an absolute type name, this program is loaded into a new additional program group or into the current program group, depending on the program type, if it has not yet been loaded. If required, the program constructor is also executed in this case.

Alternative 6

... clif=>(attr_name)


Effect

This form may be used for all visible static attributes. The class or interfaces is specified directly, and the attribute specified dynamically in a character-like field attr_name. The system searches for the attribute in the specified class or interface.

The content of attr_name does not have to be in uppercase letters. attr_name 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.

Example

Different dynamic assignments of a static class attribute to field symbols.






Vendor Master (General Section)   General Data in Customer Master  
This documentation is copyright by SAP AG.

Length: 7741 Date: 20240419 Time: 080558     sap01-206 ( 119 ms )