ABAP Objects, Interfaces This example demonstrates the use of interfaces.
ABAP_SOURCE_CODE ABAP_EXEC >
ABAP_DESCRIPTION This example shows a status> interface for outputting the attributes of an object and its implementation in two different classes. The status> interface contains a write> method. The counter> and bicycle> classes implement the interface in the public area. Both classes must implement the interface method in the implementation part corresponding to the required semantics. First, two class reference variables are declared, count> and bike>, for the classes counter> and bicycle>. An interface reference variable status> and an internal table status_tab> with a suitable row type for the interface reference variable, are created for the status> interface. All the reference variables begin with initial values. Using the CREATE OBJECT> statement, an object is created for each class, to which the references in count> and bike> point. Using the class reference variable, the increment> and drive > methods are called in the respective objects. Through the addition of the class reference variables to the interface reference table, the rows in status_tab> also point to the two objects. Using the interface references, it is possible to call the interface method write> in the objects, but not the class methods increment> or drive>. Message text extract from SAP system. Copyright SAP SE.
Search for further information about these or an SAP related objects
Comments on this SAP object
What made you want to lookup this SAP object? Please tell us what you were looking for and anything you would like to be included on this page!