SAP INHERITANCE STATICAL



Get Example source ABAP code based on a different SAP table
  



ABAP_OBJ - Inheritance and Static Components
Static components, like all components, exist only once in each inheritance tree, and can be used as of the declaring class:
A subclass can access all non-private static components of its superclasses. The class in which the static component is declared is always addressed.
From outside, the class component selector can be used to access all visible static components. Each class can be specified in which the component exists, that is, the declaring class and each subclass. Regardless of the class name used in the class component selector, however, the class in which the component is declared is always addressed.
The class in which the component is declared is always the class addressed, regardless of whether the static component is used internally or externally. This is important in the following cases:
Calls of the static constructors. Static constructors are called the first time a class is addressed. If a static component is addressed using the class name of a subclass, but is declared in a superclass, only the static constructor of the superclass is called.
Access to the static attributes A subclass has access to the content of all non-private static attributes of all superclasses. Conversely, a superclass shares its p ublic and protected static attributes with all subclasses. When inherited, static attributes are therefore not only usable in a single class but can also be used in the subtree of the inheritance tree that consists of all subclasses of the defining class. Changes to the values are visible in all involved classes, regardless of the class used to address an attribute.
Registrations of event handlers. If an event handler is declared for a static event of a subclass inherited from a superclass, it can only react to this event if it is raised by a method of the subclass or one of its subclasses. If the event is raised in a static method of a superclass, it is not handled, even if the method is called in a subclass or if the name of the subclass is specified.



Latest notes:

A static attribute of a class can be declared as a private attribute to prevent it from being used by all subclasses.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Call of a static method of a superclass using the name of a subclass. Before the method is executed, the static constructor of the superclass is executed, but not the static constructor of the subclass. The method returns the value that is set in the superclass.
ABEXA 01052
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
This example shows how a subclass is used to change a static attribute of a superclass, and how the change is visible in a subclass of a different path in the inheritance tree.
ABEXA 01053
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
Events in Inheritance
ABAP_EXAMPLE_END