Ansicht
Dokumentation

ABENCLASS_METHODS - CLASS METHODS

ABENCLASS_METHODS - CLASS METHODS

General Material Data   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.
SAP E-Book

- Methods of Classes

Methods are internal procedures of a class that determine the behavior of an object. They can access all attributes of all instances of their class and can therefore change the status of an object. Methods have a parameter interface that is used to supply them with values when they are called, and which can be used to return values to the caller. The private attributes of a class can only be changed using methods of the same class.

Definition

A method meth is declared in the declaration part of a class using the statements METHODS and CLASS-METHODS and implemented in the implementation part of the class using the following processing block:

METHOD meth.
  ...
ENDMETHOD.

As in all procedures, local data types and data objects can be declared in methods. Methods are called statically using the expression meth( ... ) or dynamically using the statement CALL METHOD (known as a dynamic invoke).

Note

In the methods of a class, one method of the class hides a built-in function with the same name. This hiding is independent of the type and number of method parameters and the type and number of arguments of the function. This means that a method should not have the same name as a built-in function.

Instance Methods

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

Note

Any attempt to call an instance method using an initial object reference variable raises a catchable exception.

Static Methods

Static methods are declared using the statement CLASS-METHODS. It can access static attributes of a class and it can only raise static events.

Constructors

In addition to the regular methods that are called explicitly, there are two special methods called constructor and class_constructor, which are called implicitly when an object is created or when a class component is accessed for the first time.

Functional Methods

Functional methods are methods with exactly one RETURNING parameter and any number of other formal parameters. Functional methods cannot just be called as standalone statements, but also as functional method calls in operand positions for functions and expressions. Here, they can be also be combined into method chainings.

Optional Methods

In interfaces, methods can be made optional using the addition DEFAULT of the statements METHODS and CLASS-METHODS. An optional interface method does not need to be implemented explicitly in a class when an interface is implemented. Instead, the definition defines a default behavior for calls of non-implemented methods. DEFAULT IGNORE calls an empty method and DEFAULT FAIL raises an exception.

Special Methods

AMDP Methods

AMDP methods are implemented as ABAP Managed Database Procedures using the addition BY DATABASE PROCEDURE or BY DATABASE FUNCTION in a database-specific language and executed in the database system.

Kernel Methods

For internal use, kernel methods are implemented in the kernel using the addition BY KERNEL MODULE.






Vendor Master (General Section)   PERFORM Short Reference  
This documentation is copyright by SAP AG.

Length: 6015 Date: 20240510 Time: 141016     sap01-206 ( 75 ms )