Monday, February 7, 2011

Redefining methods in subclass

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):


Demo for use of super keyword in redefinition:

Go to transaction SE38.

After execution (F8):


No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)


Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive