Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Declarations →  Declaration Statements →  Classes and Interfaces →  Components in Classes and Interfaces →  Implementing and including interfaces →  INTERFACES 

INTERFACES - ABSTRACT, FINAL, DATA VALUES

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


INTERFACES intf 
  [PARTIALLY IMPLEMENTED]
  { {[ABSTRACT METHODS meth1 meth2 ... ]
     [FINAL METHODS meth1 meth2 ... ]}
  | [ALL METHODS {ABSTRACT|FINAL}] }
  [DATA VALUES attr1 = val1 attr2 = val2 ...].

Extras

1. ... ABSTRACT METHODS meth1 meth2 ...

2. ... FINAL METHODS meth1 meth2 ...

3. ... ALL METHODS {ABSTRACT|FINAL}

4. ... DATA VALUES attr1 = val1 attr2 = val2 ...

Effect

In the public visibility area, the statement INTERFACES implements the interface intf in the class. Additions can also be defined to determine the properties of interface components in the class.

Any local or global interfaces can be specified for intf here that are not already included in a superclass of the current class. The components of the interfaces become public components of the class after the implementation. An interface component called comp has the name intf~comp in the class, where intf is the name of the interface and the character ~ is the interface component selector. A class must implement all methods of the interface in its implementation part, with the following exceptions:

  • Interface methods declared as optional using the addition DEFAULT.
  • Interface methods specified in the class after the addition ABSTRACT METHODS (making them abstract).
  • Partial implementations are permitted in test classes using the addition PARTIALLY IMPLEMENTED.


Notes

  • A class can implement any number of different interfaces. All of the interfaces implemented by a class are of equal status. If one of the interfaces intf implemented in a class is a composite, for example, containing component interfaces, then these are implemented in the class irrespective of their nesting hierarchy like individual interfaces and their components are not called using the name intf but using the name of their component interface. Multiple use of the interface component selection in a name (such as intf1~intf2~comp) is generally not supported.
  • Each interface appears only once in a class and every interface component compis always clearly accessible using the intf~comp. When the components of an interface, if they are components of more than one interface, appear to be used more than once in a class, even they appear only once.
  • If the implementation of a non-optional method of a global interface implemented using INTERFACES is missing in a class, a syntax warning occurs instead of a syntax error. This prevents classes from becoming unusable when later enhancements are made to global interfaces. Calls of a missing implementation, however, always raise an exception of the class CX_SY_DYN_CALL_ILLEGAL_METHOD and produce the runtime error CALL_METHOD_NOT_IMPLEMENTED if the exception is not handled. An real syntax error is produced when local interfaces are used and the implementation is missing.
  • If a class implements in its implementation part an intf~... method of a global interface intf that is implemented with INTERFACES and if it is not declared in the interface, then a warning is displayed in the syntax check. This type of method implementation is dead code that cannot be executed and should be removed. Classes become unusable with a syntax error if methods were later deleted from an implemented global interface, and which were implemented without class and had no values. An actual syntax error results when local interfaces are used.

Addition 1

... ABSTRACT METHODS meth1 meth2 ...

Addition 2

... FINAL METHODS meth1 meth2 ...

Effect

Using the additions ABSTRACT METHODS and FINAL METHODS, the individual instance methods meth of the interface are made either abstract or final in the class to be implemented. The same rules apply as for the additions ABSTRACT and FINAL of the METHODS statement. In particular, the whole class must be abstract if an interface method is made abstract and no interface methods can be executed at the same time after ABSTRACT METHODS and FINAL METHODS.

Addition 3

... ALL METHODS {ABSTRACT|FINAL}

Effect

Instead of making individual interface methods in the class abstract or final it is possible, using the addition ALL METHODS {ABSTRACT|FINAL}, to make all interface methods either abstract or final.

Addition 4

... DATA VALUES attr1 = val1 attr2 = val2 ...

Effect

Using the addition DATA VALUES, initial values can be assigned to individual attributes attr. For instance attributes, this addition fulfills the same functions as the addition VALUE of the statement DATA for attributes in its own class. Constants declared in the interface by the statement CONSTANTS cannot be specified after the addition DATA VALUES. Furthermore, it is not currently possible to specify alias names.


Note

To specify values for the interface attributes of the component interfaces of a compound interface, the component interface must currently be directly bound again using the INTERFACES statement.