Hello,

Sign up to join our community!

Welcome Back,

Please sign in to your account!

Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

SAP EWM Help Latest Questions

  • 0
  • 0
DPM125

Types of Inheritance in SAP OOABAP

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.
    METHODSdisplay.
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.
    METHODSmethod_gp.
ENDCLASS.

CLASS parent DEFINITION INHERITING FROM grandparent.
  PUBLIC SECTION.
    METHODSmethod_p.
ENDCLASS.

CLASS child DEFINITION INHERITING FROM parent.
  PUBLIC SECTION.
    METHODSmethod_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.

Related Questions

Leave an answer

Leave an answer