ABAP Objects

ABAP Objects is the Object Oriented (OO) extension to the ABAP Language. It is available since releases 4.5 and 4.6. Inheritance, dynamic method invocation and nested interfaces are included since SAP R/3 Release 4.6.

The ABAP Objects Extension is nearly 100% upward compatible.Some obsolete language elements were left out from the OO context (that is, in classes), allthough they still work in regular ABAP code. That's why it is not 100% upward compatible.

Reasons for the ABAP Object Extension

These are the reasons that led SAP into creating the ABAP Object Extension:

  • BOR, the Business Object Repository had an OO view of ths system to the outside; by the extension, the inside and outside would be coherent
  • Take advantage of OO benefits, like encapsulation, a better control of complexity, reuse of code...
  • As a new GUI programming model would be presented in release 5.0, OO presented advantages in order to achieve this new model

ABAP Objects Goals

The goals for this new ABAP Extension were:

  • The resulting language had to be simple
  • Take advantage of proven OO benefits, and not include concepts that would not benefit the language
  • Comply external standards, to allow mapping to CORBA and UML
  • A stronger typing should be required

ABAP Objects Basics

Classes are the basis of ABAP Objects. A class is a piece of program code that desccribes objects by their components: attributes, and methods. Attributes define the object state and methods their behaviour. In this perspective, an object is an instance of a class; there may be several instances of a class alive at the same time, each one with its own characteristics (attributes and methods).

The ABAP Objects extension provides new sentences to define classes, handle objects, manipulate objects, etc. These sentences are not restricted to a special type of program or code, they may be included in any section of ABAP code.

These concepts of OO programming benefits encapsulation; that is, the implementation is separate from the interface. To enforce this concept, ABAP Objects implements different sections in classes: public and private (there may be another section, called protected, used for inheritance). The public section may be accessed by all users creating an external point of contact. On the other hand, the private section may be only accessed within the class itself or objects of the same class. This behaviour is useful to ensure consistency, and making the implementation of the class independent from the definition: from an outside point of view, it is not relevant the way that private methods work.

In regular ABAP, instances exist only for ABAP programs or function groups. When a program is run, the program instance for that program is implicitly created. If that program calls an external procedure, a new instance is created for it. But repeated calls of the same external procedure use the same instance, as long as the main program is active. These instances can't be handled explicitly by the user.

ABAP Objects admits handling explicitly these instances using instances of classes. When a class is instantiated, a new instance is created for each one of them and so they have an identity by themselves, and live for the time needed.

If you would like to get more information about ABAP Objects, try searchinf for "ABAP Objects" in the SAP Help Portal.