Tuesday, June 23, 2009

Classes

The type of an object is known as its class. A class is an abstract representation, or, metaphorically speaking, a set of instructions for building objects. So that you can describe the properties of objects, classes contain components, which define the state and behavior of objects.

Global and Local Classes

You can define classes globally in the class library in the repository or locally in an ABAP program.

Global classes are coded in a special ABAP program, a class pool, whereas local classes can be coded in almost every ABAP program. Global classes can be used and are visible in all ABAP programs, which is the case for local classes only in their own program. When a global class is used for the first time, the class pool is loaded into the internal mode of the user. The local classes of a class pool can be used by the pool's global classes.

Except for the storage type and the visibility, there are hardly any conceptual differences between global and local classes. One of the few differences is that in the public interface of a global class only references to public types are possible. These types are subdivided into global and local friends.

In principle, it also does not make any difference if you call a method of a local or global class. This is the reason why classes that are used by several programs are exclusively created in the class library. You should avoid, if possible, to reuse local classes using include programs.

No comments:

Blog Archive