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 must be specified for instance components and the class with an object component or class component selector for static components. There are static and dynamic variants.

For static access, reference variables can be used to access only those components that are known to the reference variable - that is the components available in the object type used for assigning types (class or interface). Class references that are typed with reference to a superclass but indicate 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 references. This is the object type which the reference indicates and not the type used for typing the reference. For interface references the static type is also used for dynamic access, that is the type 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 references to access class-specific components dynamically; only the associated interface components can be accessed. It is not possible to access class-specific components with interface references, because, when accessing with interface references, you always have to implicitly use the ifac~ prefix.

Static Access

The following syntax applies (ref is a reference variable):

In addition to reference variables, the class name can be used for access:

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 Atributes

You can dynamically access attributes using the dynamic ASSIGN with field symbols.

You can use the following variants:

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 (ref is a 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 special internal tables, similarly to calling function modules.