SAP INHERITANCE ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_OBJ - Inheritance
This example demonstrates how a counter is specialized using inheritance.

ABAP_SOURCE_CODE
DEMO CL_DEMO_INHERITANCE

ABAP_DESCRIPTION
The local class counter_ten is derived from counter and redefines the method increment. In counter, the visibility of the attribute count must be set from PRIVATE to PROTECTED . In the redefined method, the hidden method with the pseudo reference super-> is called. The redefined method specializes the inherited method.
An object of the subclass is created to which a reference variable of the superclass type points. When the method increment is executed using the superclass reference, the redefined method of the subclass is executed.