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

How to access a parent class methods using child class object

Former Member
0 Likes
2,805

Hi

In ABAP

I have a Parent class with a method parent_method().

Child class in inheriting from Parent and redefining the parent_method().

In my z_program

I am creating a object of Child class and i want to access the parent_method in the Parent class.

Restrictions:

==>I don't want to call the child class method and then from there call the super class method.

regards

Murugesh

6 REPLIES 6
Read only

Former Member
0 Likes
1,239

Murugesh,

Did you try Super->parent_method?

Regards,

Ravi

Note : Please mark the helpful answers

Read only

0 Likes
1,239

Hi Guys,

Thanks ...

As i had mentioned that i don't want to call the child method that inturn will call super->parent_method.

Is there any otherway of doing it?

Thanks

Murugesh

Read only

0 Likes
1,239

Hello Murugesh,

The keyword SUPER points to the Superclass directly. It is <b>not</b> routed through the subclass.

However, the SUPER keyword can only be used within a method of the subclass.

Regards,

Anand Mandalika.

Read only

0 Likes
1,239

Murugesh,

Unless its inside the code of child method, it will not know which class is the parent class. Other wise you will have to find out manually which is the super class and call the method. But again I am not sure if you can specify the name of the class dynamically !

Regards,

Ravi

Read only

0 Likes
1,239

Hi,

I trying to use something like this,

child->method2();

method2()"child class method.

{

super->parent_method().

}

i got an error saying that we can't call like this..which is possible in case of JAVA.

regards

Murugesh

Read only

Former Member
0 Likes
1,239

Hello Murugesh,

The following link shows you how to do that -

http://help.sap.com/saphelp_46c/helpdata/en/1d/df5f57127111d3b9390000e8353423/frameset.htm

Regards,

Anand Mandalika.