Extending Subclasses 

Changes to subclasses are additive, that is, you cannot delete a component from a class if it was inherited from a superclass. However, you can extend a subclass as follows:

You can only redefine instance methods. Attributes, class methods, and other inherited components of a subclass cannot be redefined.
Furthermore, the methods that you want to redefine may not have been defined as final methods in the superclass. Constructor methods may not be redefined, since they are implicitly final.
A method redefinition may only extend to a new implementation of the method. The signature (names and types of the parameters) may not be changed. The interface of the redefined method must remain the same as that of the original method in the superclass.

Procedure

Adding New Components

You can define new components in all three visibility sections (public, protected, and private) of a subclass. Since both inherited and new components belong to the same namespace, you must ensure that all components in the class have unique names.
See also:

Creating Attributes

Creating Methods

Creating Events

Redefining Methods

To redefine an inherited method in a subclass from the class editor:

  1. Display all methods of the subclass (select the With inherited checkbox).
  2. The system displays the inherited methods of all subclasses.

  3. Double-click the method you want to redefine.
  4. A message appears, informing you that the method is already implemented in the superclass.

  5. Choose Continue.
  6. The ABAP source code of the original method implementation appears.

  7. Switch to change mode and reimplement the method.
  8. Check the syntax.
  9. Save your source code.
  10. Document the newly-defined method by choosing the Documentation function from the Methods display.

Result

You have now extended the class, and your new components are visible, as well as the public and protected components of the superclass. Redefined methods appear in a different color in the class editor.
If you redefine a method in a subclass, the corresponding original method in the superclass remains unchanged.

You can access all visible components in the subclass in the same way - inherited components can also be addressed using their local name. If, however, you need to address components of the direct superclass, you can use the pseudoreference SUPER.

For further information, refer to the section on visibility of components.