Statements for Defining Classes and Interfaces

The following statements are used to defined classes and interfaces and their components. You can use them in any ABAP program in which class and interface definitions are allowed.

Defining Classes

Defining the Declaration Part

CLASS ... DEFINITION ...
...
ENDCLASS ...

Defining the Implementation Part

CLASS ... IMPLEMENTATION ...
...
ENDCLASS ...

Defining Class Components

Statements in the Declaration Part

PUBLIC SECTION.
PROTECTED SECTION.
PRIVATE SECTION.

TYPES ...
TYPE-POOLS ...

INTERFACES ...
ALIASES ...

CONSTANTS ...

CLASS-DATA ...
DATA ...

CLASS-METHODS ...
METHODS ...

CLASS-EVENTS ...
EVENTS ...

Statements in the Implementation Part

METHOD ...
...
ENDMETHOD.

Defining Interfaces

Defining the Interface

INTERFACE ...
...
ENDINTERFACE ...

Statements for Defining Interface Components

You can use the same statements to define interface components as to define class components.

Note

In the declaration part of a class or in interface, you define its components, that is, its attributes, methods, and events. You can declare local data types using the TYPES statement and declare type groups from the ABAP Dictionary using the TYPE-POOLS statement. You can also declare alias names for the components of implemented interfaces using the ALIASES statement. In a class, all declarations must belong to one of the three visibility sections, introduced by the relevant statement.

The implementation part of a class may only contain method implementations in METHOD - ENDMETHOD blocks. In a method, you can only use the statements for method implementations.

No statements other than those listed above are necessary for defining classes or interfaces. Consequently, no other statements are allowed between CLASS and ENDCLASS or INTERFACE - ENDINTERFACE except within methods.

The tightened syntax in ABAP Objects applies to all class and interface definitions.