Class Pools 

This section discusses the structure and special features of class pools.

Global Classes and Interfaces

Classes and interfaces are both object types. You can define them either globally in the R/3 Repository or locally in an ABAP program. If you define classes and interfaces globally, they are stored in special ABAP programs called class pools (type K) or interface pools (type J), which serve as containers for the respective object types. Each class or interface pool contains the definition of a single class or interface. The programs are automatically generated by the Class Builder when you create a class or interface.

A class pool is comparable to a module pool or function group. It contains both declarative and executable ABAP statements, but cannot be started on its own. Instead, the system can only execute the statements in the class pool on request, that is, when the CREATE OBJECT statement occurs to create instances of the class.

Interface pools do not contain any executable statements. Instead, they are used as containers for interface definitions. When you implement an interface in a class, the interface definition is implicitly included in the class definition.

Structure of a Class Pool

Class pools are structured as follows:

Class pools contain a definition part for type declarations, and the declaration and implementation parts of the class.

Differences From Other ABAP Programs

Class pools are different from other ABAP programs for the following reasons:

Local Classes in Class Pools

The classes and interfaces that you define in the definition part of a class pool are not visible externally. Within the class pool, they have a similar function to local classes and interfaces in other ABAP programs. Local classes can only be instantiated in the methods of the global class. Since subroutines are not allowed in class pools, local classes are the only possible modularization unit in global classes. Local classes have roughly the same function for global classes as subroutines in function groups, but with the significant exception that they are not visible externally.