SAP INTERFACE ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_OBJ - Interfaces
This example demonstrates the use of interfaces.

ABAP_SOURCE_CODE
DEMO CL_DEMO_INTERFACE

ABAP_DESCRIPTION
This example shows a local interface status for displaying the attributes of an object and its implementation in two different local classes.
The interface status contains a method write. The classes counter and bicycle implement the interface in the public area. Both classes must implement the interface method in the implementation part according to the required semantics.
First, two class reference variables count and bike are declared for the classes counter and bicycle. An interface reference variable status and an internal table status_tab with a suitable line type for the interface reference variable are created for the interface status. All reference variables begin with initial values.
Using the constructor operator NEW, an object is created for each class to which the references in count and bike point. Using the class reference variable, the methods increment and drive are called in the respective objects.
Class reference variables are inserted in the interface reference table to have the lines in status_tab point to the two objects as well. Using the interface references, it is possible to call the interface method write in the objects, but not the class methods increment or drive.