Accessing Class Components

When accessing class components, there is a difference between access from inside and outside the same class. When a component is accessed from inside, that is within a method of the same class, the name of the component is sufficient. When a component is accessed from outside, the object for instance components and the class for static components must be specified with an object component selector or class component selector. There are static and dynamic variants.

For static access, object reference variables can only be used to access components that are known to the reference variable. These are the components that are available in the object type used in the static type (class or interface). Class reference variables that are typed with reference to a superclass but point to subclasses know only the superclass components. Interface references know only interface components.

With dynamic access, the dynamic type is used to get the component for class reference variables. This is the type of the object to which the reference refers, and not the type used for typing the reference. For interface reference variables the static type is also used for dynamic access, that is, the type that was used to type the reference.

This means that reference variables that have been typed with reference to a superclass. They point to subclasses that can be used to dynamically access any component of the subclass for which dynamic access is possible. In particular, reference variables of the type REF TO OBJECT can be used to dynamically access components. However, it is not possible to use interface reference variables to access class-specific components dynamically; only the associated interface components can be accessed. It is not possible to access class-specific components using interface reference variables, because, when accessing with interface reference variables, you always have to implicitly use the intf~ prefix.

Static Access

The following syntax applies (oref is an object reference variable):

In addition to reference variables, the class name can be used for accessing static components :

In this context it is important to note that the properties of instance methods behave like static components. Therefore, in a LIKE addition you can use the class component selector or reference variables to refer to visible attributes of a class, without first creating an object.

In addition to specifying the name, accessing the components of a class is also possible using self-reference me:

Self-reference allows an object to transfer a reference to itself to other objects. In addition, attributes within an object can be accessed in methods which are obscured by the local attributes of the method.

Within a redefined method of a subclass you can use the pseudo reference super to access the obscured method in one of the superclasses:

Within the instance constructor of a subclass, the pseudo reference super must be used to call the instance constructor of the direct superclass:

As a specific method for accessing attributes, you can use attributes for key access to internal tables if they contain reference variables.

Dynamic Access

Dynamic access to class components is only possible for attributes (dynamic access) and for method calls (dynamic invoke).

Dynamically Accessing Attributes

Dynamic access to attributes is possible using the dynamic ASSIGN to field symbols

The following variants can be used (oref is an object reference variable):

The contents of the fields f, f1 and f2 are interpreted as descriptors of attributes. In a completely dynamic case, f can, for example, have the content 'oref->attr'. In the case of the partly dynamic specification for instance attributes, f only describes the attribute (which itself can in turn describe another attribute). f1 and f2 can be class names and static attributes.

Dynamic Method Calls

The following syntax applies (oref is an object reference variable):

f and c are fields containing the name of the method meth or class class.

In the case of dynamic method calls, you can dynamically transfer the actual parameter into specific internal tables, similarly to calling function modules.