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

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

[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

Question from pathakvikash72 on Jan 12 at 7:48 AM
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
pathakvikash72  

achievement
 
View this online
Ask a new question
 
In the Spotlight
Earn Recognition for Your Contributions at Toolbox for IT. Gain Points for Community Achievements

_.____.__

0 comments:

Post a Comment

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