We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

RE: [sap-abap] How To Call Parent Class Method Using Sub Class Object

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Reply from robphelan on Jan 12 at 9:47 AM
Can't you just create an instance of the parent class and call the method just like you did with the child class?

---------------Original Message---------------
From: pathakvikash72
Sent: Thursday, January 12, 2017 7:51 AM
Subject: How To Call Parent Class Method Using Sub Class Object

Hello friends,

I have a question in OOPS ABAP,

I have two class class_parent and class_child , and child class is inheriting parent class and using same method in child class but different implementation , so i s there a way that we could call parent method from child class object Eg.

CLASS CLASS_PARENT DEFINITION.

PUBLIC SECTION.

DATA: A TYPE I,

B TYPE I,

C TYPE I.

METHODS: DISPLAY.

ENDCLASS.

CLASS CLASS_PARENT IMPLEMENTATION.

METHOD DISPLAY.

C = A B.

WRITE:/ C.

ENDMETHOD.

ENDCLASS.

CLASS CLASS_CHILD DEFINITION INHERITING FROM CLASS_PARENT.

PUBLIC SECTION.

DATA: A1 TYPE I,

B1 TYPE I,

C1 TYPE I.

METHODS: DISPLAY REDEFINITION. "REDEFINE THE SUPER CLASS METHOD ENDCLASS.

CLASS CLASS_CHILD IMPLEMENTATION.

METHOD DISPLAY.

C1 = A1 * B1.

ENDMETHOD.

ENDCLASS.

*CREATE THE OBJECT FOR SUB CLASS.

DATA: OBJ TYPE REF TO CLASS_CHILD.

START-OF-SELECTION.

CREATE OBJECT OBJ.

CALL METHOD OBJ->DISPLAY.

So is there a way that we could access CLASS_PARENT method from object OBJ

Thanks in Advance

 
Reply to this email to post your response.
 
__.____._
Manage Settings | Unsubscribe | Create FAQ | Send Feedback
  
© 2017 Ziff Davis, LLC. and message author.
Ziff Davis, LLC. 28 E 28th Street New York, NY 10016
robphelan  

16 achievements
 
Mark as helpful
View this online
Ask a new question
 
In the Spotlight
Have a technical question? Need to find IT solutions? Ask your peers in the Toolbox for IT community.

_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language