Interface in SAP ABAP
The interface in SAP ABAP is different from the class, it can not have any implementation like the class. It defines a set of method declarations that a class must implement without providing any implementation detail of that method. Interface helps in achieving multiple inheritance. Multiple inheritance can be defined as a class can inherit multiple interfaces. Due to Inheritance interface provides a base for polymorphism because the method declared in the interface behaves differently in different classes. Like class Interface can be defined locally or globally in the ABAP programming language.
Example:
CLASS Your_Class DEFINITION.
PUBLIC SECTION.
INTERFACES: Your_Interface.
ENDCLASS.
CLASS Your_Class IMPLEMENTATION.
METHOD Your_Interface~method1.
" Implementation for method1
ENDMETHOD.
METHOD Your_Interface~method2.
" Implementation for method2
ENDMETHOD.
" ... Implement other methods from the interface
ENDCLASS.
Abstract Class Vs Interface in SAP ABAP
In this article, we are going to learn the difference between an Abstract Class and an Interface in SAP ABAP. It is created by SAP which is a domain-specific language, it is 4th generation programming language. It is also called ABAP/4(Fourth Generation Language” or 4GL).