Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Declarative statemnts →  Classes and Interfaces →  ABAP Objects - Overview 

Objects

Objects are instances of classes. There can be any number of objects or instances in a class. Each object has a unique identity and its own attributes.

As standard, all objects have the same priority in the data area of an internal session. This means that objects can only be accessed from within an internal session.

For transaction-independent objects, shared objects are available, which can be accessed by all programs of an application server at the same time.

Object Services are available for handling persistent objects in the database. These link the attributes of objects with the content of database tables and can execute object-oriented transactions.

Other versions: 7.31 | 7.40 | 7.54

Creating Objects

If you want to create an object, you need an object reference variable that can point to the required class:

  • Having declared a class reference variable obj for a class class, you can create an object of that class using the statement CREATE OBJECT obj. This statement creates an instance of the class class and the reference variable obj contains a reference to this object.
  • Having declared a class reference variable obj for a superclass of the class class or an interface reference variable obj for an interface implemented by the class class, you can use the TYPE class addition of the CREATE OBJECT obj statement to create an instance of the class class.

Access to Instance Components

A program can access the visible instance components of an object only through references in reference variables. For the syntax, see Accessing Components of Classes.

Lifetime of Objects

An object is kept alive for as long as it is used in the internal session (Heap). The system will continue use the object provided that at least one Heapreference points to the object, an instance attribute or part of the instance attribute or provided that at least one method of the object is registered as an event handler. Field symbols to which an instance attribute or part of an instance attribute is assigned still work in the same way as data references.

As soon as an object has no more references and none of its methods is registered as an event handler, it can be deleted by the Garbage Collector). This releases the identity of the object to be taken by a new object.


Note

Alongside these regular references, weak references represented by objects exist that do not keep an object alive.

Continue

Object References

Accessing Class Components

Object References in Internal Tables

Weak References