ABAP Keyword Documentation → ABAP - Reference → Declarative statemnts → Classes and Interfaces → ABAP Objects - Overview → Classes → Components of Classes
Methods
Methods are internal procedures of a class that determine the behavior of an object. They can access all the attributes of all instances of their class and can therefore change the status of an object. Methods have a parameter interface, used by the system to pass values to them when they are called, and by which they can return values to the caller. The private attributes of a class can only be changed using methods of the same class.
A method meth
is declared in the
declaration section of a class and is implemented in the
implementation part of the class using the
processing block
METHOD meth.
...
ENDMETHOD.
As in all procedures, local data types and data objects can be declared in methods. Methods are called
using the CALL METHOD
statement or one of its abbreviated forms. The method can also be called dynamically (dynamic invoke.
Other versions: 7.31 | 7.40 | 7.54
Instance Methods
Instance methods are declared using the METHODS
statement. They can access all the attributes of a class and can trigger all its events.
Static Methods
Static methods are declared using the CLASS-METHODS
statement. This statement can access
static attributes of a class and is can trigger
static events only.
Constructors
As well as the normal methods that are called using CALL METHOD
, there are
two special methods called constructor
and class_constructor
, which are called automatically when an object is created or when a class component is accessed for the first time.
Functional Methods
Functional methods are methods with any number of IMPORTING
parameters and
one RETURNING
parameter. Functional methods cannot just be called using CALL METHOD
, but also as
functional method calls in
operand positions for functions and expressions. Here they can be also be combined as
method chainings.