Methods

Methods are the internal procedures of a class that determine the behavior of an object. They can access all the attributes of their class and can thus change the object status. Methods have a parameter interface, through which the system passes values to them when they are called, and through which they can return values to the caller. The private attributes of a class can only be changed using methods.

In terms of definition and passing parameters, methods are similar to the old function modules. A method meth is declared in the declaration part of a class and implemented in the implementation part using the

METHOD meth.
...
ENDMETHOD.

processing block. You can declare local data types and data objects in methods, just as in other ABAP procedures (subroutines and function modules). The CALL METHOD statement is used to call methods, but when you call a static method you can omit the CALL METHOD statement. You can also call the method dynamically (dynamic invoke).

Instance methods

Instance methods are declared using the METHODS statement. They can access allthe attributes of a class and can trigger all its events.

Static methods

Static methods are declared using the CLASS-METHODS statement. They can access static attributes of a class and can trigger static events.

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. Apart from using CALL METHOD you can also use the following expressions to insert functional methods at operand positions:

At present, you can use functional methods in the following situations:

The functional method replaces an operand. When the statement is executed, the method is called and the RETURNING parameter is used as an operand.