Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

information regarding multiple inheritance

Former Member
0 Likes
973

Hi Experts,

Plz could any one explain me about why multiple inheritance is not used in sap..

thanks in advance,

Sana..

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
0 Likes
870

Multiple inheritance is an idea where more than one class can be a superclass of a class. This is used in C++, for example. In Java and ABAP, the designers of the programming language decided this was a BAD idea, leading to ambiguity and contradiction - and therefore, programs that are more complicated and expensive to maintain.

So, the biggest reason is: the clever people at SAP decided not to allow multiple inheritance.

matt

4 REPLIES 4
Read only

Former Member
0 Likes
870

Hi,

we need not to use multiple inheritence in ABAP because we are using Interfaces.

Interfaces are independent structures that you can implement in a class to extend the scope of that class.

a universal point of contact.

They provide one of the pillars of polymorphism, since they allow a single method within an interface to behave differently in different classes.

Global & Local Interfaces

The definition of a local interface <intf> is enclosed in the statements:

INTERFACE <intf>.

...

ENDINTERFACE.

The definition contains the declaration for all components (attributes, methods, events) of the interface.

They automatically belong to the public section

please reward points, if it is useful.

regards,

satish.

Read only

matt
Active Contributor
0 Likes
871

Multiple inheritance is an idea where more than one class can be a superclass of a class. This is used in C++, for example. In Java and ABAP, the designers of the programming language decided this was a BAD idea, leading to ambiguity and contradiction - and therefore, programs that are more complicated and expensive to maintain.

So, the biggest reason is: the clever people at SAP decided not to allow multiple inheritance.

matt

Read only

Former Member
0 Likes
870

Hi ,

ABAP Objects does not support multiple inheritance to make it as simple as possible.

    In multiple inheritance,  If the classes a2 and a3 inherit from a class a1, both contain all the components of a1. Now, if class a4 becomes a subclass of both a2 and a3, the problem arises of how to merge the original components of a1 into a4.

Thanks

Santosh

Read only

naimesh_patel
Active Contributor
0 Likes
870

ABAP doesn't support Multiple Inheritance from classes, but you can achieve the similar functionality using Interfaces. Check out ABAP Objects – Achieve Multiple Inheritance using Interfaces

Only thing you can't achieve using this workaround is the redefinition on the methods in the concrete class if you wish to use the default functionality.

Regards,
Naimesh Patel