SAP METHODS ABSTRACT FINAL ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• ABSTRACT METHODS
• FINAL METHODS

METHODS, ABSTRACT, FINAL
Short Reference

ABAP_SYNTAX
METHODS meth ... ABSTRACT$|FINAL ...

ABAP Addition
1 ... ABSTRACT
2 ... FINAL

What does it do?
The additions ABSTRACT and FINAL make an instance method abstract or final. They cannot be used in interfaces, only in classes. All instance methods can be declared as abstract except for instance constructors. The addition FINAL can be used in all variants of the statement METHODS.

ABAP Addition

What does it do?
The addition ABSTRACT defines an abstract method meth . The addition ABSTRACT is allowed only in abstract classes, not in interfaces. An abstract method is not implemented in the implementation part of its class. To implement an abstract method, it must be redefined in a specific subclass using the addition REDEFINITION. Private methods cannot be redefined and can therefore not be declared as abstract.



Latest notes:

Abstract methods can also be defined in classes that are both abstract and final, but they can never be implemented and therefore are not usable.
Methods in interfaces are always implicitly abstract, because interfaces do not contain method implementations.
With the exception of the instance constructor, concrete instance methods of a class can also call their abstract methods.
Static methods cannot be redefined, and the addition ABSTRACT is not allowed in their declarations.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Declaration of an abstract method of an abstract superclass and its implementation in a concrete subclass.
ABEXA 00413
ABAP_EXAMPLE_END

ABAP Addition

What does it do?
The addition FINAL defines a final method meth. The addition FINAL is allowed only in classes, not in interfaces. A final method cannot be redefined in a subclass. In final classes, all methods are automatically final and the addition FINAL is not allowed. An instance constructor constructor is always final and FINAL can be specified but is not mandatory.



Latest notes:

Static methods cannot be redefined, and the addition FINAL is not allowed in their declarations.
The addition FINAL closes a path of an inheritance tree with regards to the possibility to redefine the method.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The final method get_the_truth of a superclass returns a value, which cannot be changed in a subclass. Method get_opinion can be redefined in a subclass, but the subclass shown here prevents the method from being redefined in subclasses.
ABEXA 00414
ABAP_EXAMPLE_END

Return to menu