For scenarios where subclass has to change the implementation of the inherited instance method to have its own implementation, we can use method redefinition.
Method redefinition supports only re-implementation of inherited method, signature of the method cannot be changed. Also, the visibility of the redefined method should remain the same as in the parent class.
Implementation of inherited static methods cannot be changed. That is static methods does not support method redefinition.
The reference object SUPER refers to superclass. Using SUPER, we can access superclass components or original method of the superclass in redefined implementation of the method. SUPER prefix can only be used under method redefinition.
Syntax for method redefinition
CLASS superclass DEFINITION.
PUBLIC SECTION.
METHODS m1 IMPORTING .. .
ENDCLASS.
CLASS superclass IMPLEMENTATION.
METHOD m1.
...
ENDMETHOD.
ENDCLASS.
CLASS subclass DEFINITION INHERITING FROM superclass.
PUBLIC SECTION.
METHODS m1 REDIFINITION.
ENDCLASS.
CLASS subclass IMPLEMENTATION.
METHOD m1.
...
super->m1( ... ).
ENDMETHOD.
ENDCLASS.