1. Single Inheritance (Supported in ABAP)
- Definition: One subclass inherits from one superclass.
- Use: Most common form of inheritance.
CLASS parent_class DEFINITION.
PUBLIC SECTION.
METHODS: display.
ENDCLASS.
CLASS parent_class IMPLEMENTATION.
METHOD display.
WRITE: 'Parent class method'.
ENDMETHOD.
ENDCLASS.
CLASS child_class DEFINITION INHERITING FROM parent_class.
ENDCLASS.
CLASS child_class IMPLEMENTATION.
ENDCLASS.
2. Multilevel Inheritance (Supported in ABAP)
- Definition: A class inherits from a child class, which itself inherited from a parent class.
- Hierarchy: Grandparent → Parent → Child
CLASS grandparent DEFINITION.
PUBLIC SECTION.
METHODS: method_gp.
ENDCLASS.
CLASS parent DEFINITION INHERITING FROM grandparent.
PUBLIC SECTION.
METHODS: method_p.
ENDCLASS.
CLASS child DEFINITION INHERITING FROM parent.
PUBLIC SECTION.
METHODS: method_c.
ENDCLASS.
3. Hierarchical Inheritance (Supported via multilevel in ABAP)
- Definition: Similar to multilevel, but describes a tree of inheritance.
- ABAP supports this by chaining multiple single inheritances.
4. Multiple Inheritance (❌ Not Supported Directly in ABAP)
- Definition: A class inherits from more than one superclass.
- ABAP Limitation: ABAP allows a class to inherit from only one class directly.
- Alternative: Use interfaces to simulate multiple inheritance.