Tuesday, June 23, 2009

Statements for Defining Classes and Interfaces

he following statements define classes and interfaces and their components. You can use them in any ABAP program in which class and interface can be defined.

Statements for Defining Classes

Defining the Declaration Part

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

Defining the Implementation Part

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

Statements for Defining Class Components

Statements in the Declaration Part

PUBLIC SECTION.
PROTECTED SECTION.
PRIVATE SECTION.

TYPES ...

INTERFACES ...
ALIASES ...

CONSTANTS ...

CLASS-DATA ...
DATA ...

CLASS-METHODS ...
METHODS ...

CLASS-EVENTS ...
EVENTS ...

Statements in the Implementation Part

METHOD ...
...
ENDMETHOD.

Statements for Defining Interfaces

Declaring the Interface

INTERFACE ...
...
ENDINTERFACE ...

Statements for Declaring Interface Components

In interfaces, you can use the same statements to declare interface components as those used in the declaration part of classes.

Note

In the declaration part of a class or in interface, you declare its components, that is, its attributes, methods, and events. You can declare local data types using the TYPES 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 four visibility sections introduced by the relevant statement.

The implementation part of a class only contains 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 stricter syntax in ABAP Objects applies to all statements for defining classes and interfaces.

No comments:

Blog Archive