METHOD

Short Reference

Syntax

METHOD meth.
  ...
ENDMETHOD.

Addition:

... BY KERNEL MODULE p1 ...

Effect

: Between the statements METHOD and ENDMETHOD, the functions of a method meth declared with [CLASS-] METHODS are implemented in a class. Implementation of a method is only possible in an implementation part of a class that begins with CLASS class IMPLEMENTATION.

Local data types and data objects can be declared within the method. It is also possible to access the formal parameters of the method and all the components of all instances of its own class. The method and its interface are defined either using the statement [CLASS-]METHODS for a local class, or in the Class Builder tool for a global class.

In instance methods, all components of the method's own class can be addressed not only using their name, but also explicitly using the self-reference me->.

A method is called using the statement CALL METHOD or, as of Release 6.10, using one of its abbreviated forms.

Note

: Prior to Release 6.40, alias names defined using ALIASES could not be entered for meth for a method of an interface.

Example

: In this example, the two methods m1 and m2 of the class c1 are implemented between METHOD and ENDMETHOD. Although the local data object a1 conceals the attribute of the same name, the attribute a1 can be addressed using me->a1.

CLASS c1 DEFINITION.
  PUBLIC SECTION.
    METHODS m1 IMPORTING p1 TYPE string.
  PRIVATE SECTION.
    DATA a1 TYPE string.
    METHODS m2.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
  METHOD m1.
    a1 = p1.
    m2( ).
  ENDMETHOD.
  METHOD m2.
    DATA a1 TYPE string.
    a1 = me->a1.
  ENDMETHOD.
ENDCLASS.

Addition

... BY KERNEL MODULE p1 ...

Note

This statement is for internal use only.
It cannot be used in application programs.


Effect

:This addition to the statement METHOD defines the method meth as a kernel method. This means that the method meth is not implemented in ABAP, but instead is implemented in the kernel in one of the kernel modules (p1) specified here. No statements are permitted between METHOD and ENDMETHOD.