Accessibility of components by use of super in ABAP Objects
Page 1 of 1
Accessibility of components by use of super in ABAP Objects
From the above diagram it can be seen that if a method is redefined then ,the uniqueness of the method is implicitly defined by the system ,this prevents the confusion during the method call. When a redefined method is called by the super class then the method implementation in the super class is called and when the redefined method is called from the sub class then the newly defined version is called
- Code:
Example of method redefinition.
CLASS super_class DEFINITION.
PUBLIC SECTION.
METHODS super_class_method.
ENDCLASS.
CLASS sub_class DEFINITION INHERITING FROM super_class
PUBLIC SECTION.
METHODS super_class_method REDIFINITION.
ENDCLASS.
CLASS super_class IMPLEMENTATION.
METHOD super_class_method.
Write:/ ‘this is super class method’.
ENDMETHOD.
ENDCLASS.
CLASS sub_class IMPLEMENTATION.
METHOD super_class_method.
Write:/ ‘super class method is redefined in sub class’.
ENDMETHOD.
ENDCLASS.
*************** MAIN PROGRAM ****************************
START-OF-SELECTION.
Data: sub_ref type ref to sub_class, “reference for sub_class
Sup_ref type ref to super_class. “reference for super_class.
Create object: sub_ref ,
Sup_ref.
Call method sub_ref->super_class_method.
Call method sup_ref->super_class_method.
******************out put *************************
this is super class method’
super class method is redefined in sub class
Uma_ABAP- Posts : 56
Join date : 2012-03-31
Similar topics
» Static and instance components in ABAP Objects
» declaring static and instance components in ABAP Objects
» Concept of super and final in ABAP Objects
» Creating multiple Objects in ABAP Objects
» Difference between Procedural ABAP and ABAP Objects
» declaring static and instance components in ABAP Objects
» Concept of super and final in ABAP Objects
» Creating multiple Objects in ABAP Objects
» Difference between Procedural ABAP and ABAP Objects
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Mon Aug 20, 2012 4:37 pm by Admin
» Difference between Type and Like
Thu Jun 07, 2012 2:40 pm by Admin
» How to handle table control fields in Module Pool program?
Wed May 09, 2012 2:41 am by govind
» Three tables inner join in SAP
Thu May 03, 2012 4:47 pm by Uma_ABAP
» Creating table type in ABAP
Sat Apr 28, 2012 9:03 pm by Uma_ABAP
» Creating user defined types and structures in ABAP
Sat Apr 28, 2012 8:55 pm by Uma_ABAP
» Creating Dynamic Internal Table and Dynamic Field catalog in SAP-ABAP
Fri Apr 27, 2012 11:00 am by Admin
» Copy Custom PF-Status from Standard program to Custom Program in ALV
Thu Apr 26, 2012 9:52 pm by Uma_ABAP
» Calculate/find number of working days between two dates in SAP
Tue Apr 24, 2012 2:06 pm by Uma_ABAP