Ansicht
Dokumentation

ABENINHERITANCE_INCLUDE - INHERITANCE INCLUDE

ABENINHERITANCE_INCLUDE - INHERITANCE INCLUDE

ROGBILLS - Synchronize billing plans   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.
SAP E-Book

Inheritance

The concept of inheritance allows you to derive new classes from existing classes. To do this, you use the INHERITING FROM addition of the CLASS ... DEFINITION statement. The new class adopts or inherits all components of the existing class. The new class is called the subclass, and the existing class is called the superclass.

If you make no further declarations, a subclass receives exactly the components of the superclass. However, the subclass can only see those components of the superclass that belong to the public and protected visibility sections. Although the private components of the superclass are also contained in the subclass, they are not visible. In a subclass, you can define private components that have the same name as the corresponding components of the superclass. Each class works with its private components. As long as a method inherited from the superclass is not redefined, it uses the private attributes of the superclass and not the possible subclass attributes of the same name.

If the superclass does not have a private visibility section, the subclass is an exact copy of the superclass. You can, however, add further components to the subclass. These components are used to specialize the subclass in relation to the superclass. If a subclass is then used as the superclass for a new class, you can then define a further level of specialization.

Each class can have several direct subclasses, but only one direct superclass. ABAP Objects follows the principle called single inheritance. If subclasses inherit from superclasses which are, in turn, subclasses themselves, all classes involved make up an inheritance tree whose specialization increases the deeper you go in the hierarchy levels. Similarly, specialization decreases the closer you come to the root node of the inheritance tree.

The root node of all inheritance trees in ABAP Objects is the predefined empty class OBJECT. This class is the most generic class feasible because it contains neither attributes nor methods. When you define a new class, you must not explicitly specify this class as a superclass because it always exists implicitly. In the inheritance tree, two neighboring nodes are called the direct superclass and subclass, while all preceding and succeeding nodes are collectively referred to as superclasses and subclasses. The declaration of the components of a subclass is distributed among all superclasses of the inheritance tree.






ABAP Short Reference   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.

Length: 2720 Date: 20240420 Time: 144901     sap01-206 ( 72 ms )