Preface – This post is part of the Object Oriented ABAP series.
Table of Contents
So far we have learnt about the classes and interfaces, their properties, uses and many more things. We can define the class and interface either globally in the repositories or locally in the ABAP program. When the classes and interfaces are defined globally, class pools and interface pools generated by CLASS BUILDER serves as a container and each class pool and interface pool contains a single class or interface. The benefit of defining globally is that they can be accessed by any ABAP program. Whereas when defining locally, they are accessed only by their own program.
A class pool acts as the container for classes defined globally and has program type K. It is somewhat similar to module pools or function groups (act as containers) except the fact that the class pools don’t have their own screens or processing blocks than methods. It contains both declarative as well as executable statements. The CREATE OBJECT statement creates the objects to execute the statements in class pools.
The class pool is introduced by the statement CLASS-POOL in master program. The naming of the master program will contain the global class name and is padded with “=” up to 30th position and ends with “CP”.
Example, The name of the interface pool for global interface CL_DEMO_GO_CODING is CL_DEMO_GO_CODING=============CP.
Structure of Class Pool
Below is the structure of Class Pools:
The types defined in the class pool are only visible in the implementation part of the global class.
An interface pool acts as the container for interfaces defined globally and has program type J. Unlike the class pools, interface pools do not have any executable statements. They contain the interface definition which can be implemented by global and local classes. When interfaces are implemented in global class, the interface definition is also included in the class definition.
Similar to class pool, the name of the master program of interface pool contains the global interface name and is padded with “=” up to 30th position and ends with “IP”.
The name of the interface pool for global interface IF_DEMO_GO_CODING is IF_DEMO_GO_CODING=============IP.