Redefining methods in subclass

By Malya Ajimera, Capgemini consulting

Definition: The methods of the super class can be re-implemented at the sub class.  

Purpose to redefine methods: if the method implementation at the super class is not satisfies the requirement of the object which is created with reference to the sub class.

Principles of redefining methods:  

  1. The REDEFINITION statement for the inherited method must be in the same SECTION as the definition of the original method.
  2. If you redefine a method, you do not need to enter its interface again in the subclass, but only the name of the method.
  3. In the case of redefined methods, changing the interface (overloading) is not permitted; exception: Overloading is possible with the constructor
  4. Within the redefined method, you can access components of the direct super class using the SUPER reference.
  5. The pseudo-reference super can only be used in redefined methods.  

Demo program for redefining method:  

Go to transaction SE38:  

Give any name for the program.  

 

After execution (F8):  

 

Result:

 

Demo for use of super keyword in redefinition:  

Go to transaction SE38.  

 

 

After execution (F8):  

Result:  

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image