ARTICLE
Redefining Methods
Each subclass contains the components of all classes that are located
between this class and the root node in the inheritance tree. The
visibility of a component is always the same and cannot be changed.
However, it is possible to redefine the public and protected instance
methods of all preceding superclasses using the
REDEFINITION addition of the
METHODS statement in order to adjust them to
the requested specialization. The interface of a redefined method cannot
be changed. The method is merely reimplemented under the same name.
Constructors cannot be redefined; instead,
special rules apply.
The method declaration remains with the superclass, and its previous
implementation is also persisted there. The implementation of the
redefinition is generated additionally with the subclass and obscures
the implementation of the superclass. A redefined method works with the
private attributes of the subclass and not with possible private
superclass attributes of the same name.
Each reference that points to a subclass object uses the redefined
method, even if it was typed with reference to a superclass. In p
articular, this also applies to the self
reference me . For example, if a superclass method m1
contains a call [me- ]m2( ) or and if m2 is redefined in a
subclass, the call of m1 in an instance of the superclass causes
the original method m2 to be executed and the call of m1
in an instance of the subclass causes the redefined method m2 to
be executed.
Within a redefined method,
super- meth can be used to access the obscured method, for example
to adopt and supplement its functions.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved