Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Declaration Statements →  Classes and Interfaces →  Components in Classes and Interfaces →  Methods 

CLASS-METHODS

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax Forms


General Static Methods

1. CLASS-METHODS meth [DEFAULT IGNORE|FAIL]
    [IMPORTING parameters [PREFERRED PARAMETER p]]
    [EXPORTING parameters]
    [CHANGING parameters]
    [{RAISING exc1|RESUMABLE(exc1) exc2|RESUMABLE(exc2) ...}
    |{EXCEPTIONS exc1 exc2 ...}].

Functional Static Methods

2. CLASS-METHODS meth [DEFAULT IGNORE|FAIL]
    [IMPORTING parameters [PREFERRED PARAMETER p]]
    [EXPORTING parameters]
    [CHANGING  parameters]
    RETURNING VALUE(r) typing
    [{RAISING exc1|RESUMABLE(exc1) exc2|RESUMABLE(exc2) ...}
    |{EXCEPTIONS exc1 exc2 ...}].

Static Constructors (Only in Classes)

3. CLASS-METHODS class_constructor.

Event Handlers

4. CLASS-METHODS meth [DEFAULT IGNORE|FAIL]
     FOR EVENT evt OF {class|intf}
     [IMPORTING p1 p2 ... [sender]].

AMDP - Methods

5. CLASS-METHODS meth [DEFAULT IGNORE|FAIL]
                     [AMDP OPTIONS [READ-ONLY] [CDS SESSION CLIENT clnt|CURRENT]]
    [IMPORTING parameters [PREFERRED PARAMETER p]]
    [EXPORTING parameters]
    [CHANGING  parameters]
    [RETURNING VALUE(r) typing]
    [{RAISING exc1|RESUMABLE(exc1) exc2|RESUMABLE(exc2) ...}]

AMDP function implementations for CDS table functions (in classes only)

6. CLASS-METHODS meth FOR TABLE FUNCTION cds_entity.

Effect

The statement CLASS-METHODS declares a static method meth. The naming conventions apply to the name meth.

Using the class component selector (=>), static methods can be used independently of objects. In static methods, the static components of the class or its superclasses can be accessed only if the component selector is not used.

The variants of the statement CLASS-METHODS distinguish different types of method declaration:


Notes

  • Like all static components in the inheritance, the static methods of a superclass exist in all subclasses. A static method is always executed in the class in which it was declared. A static method that is visible from outside can be called using the class component selector, as can all names and classes in which it exists. The class in which it was declared is always the one that is addressed. This modifies the way the static constructor or the event handlers are executed.
  • In the methods of a class, one method of the class obscures a built-in function with the same name. This done regardless of the type and number of method parameters and the type and number of arguments on the function. This means that a method should not have the same name as a built-in function.

Continue

CLASS-METHODS - IMPORTING, EXPORTING, CHANGING, RAISING

CLASS-METHODS - RETURNING

CLASS-METHODS - class_constructor

CLASS-METHODS - FOR EVENT