SAP OBJECT

Get Example source ABAP code based on a different SAP table
  

Warning: Undefined variable $prev in /customers/b/9/9/trailsap.com/httpd.www/sap-help/index.php on line 54
ARTICLE

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.

Creating Objects
Before an object can be created, an object reference variable is required that can point to the required class:

Once a class reference variable obj is declared for a class class, an object of that class can be created 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.

Once a class reference variable obj is declared for a superclass of the class class or an interface reference variable obj for an interface implemented by the class class, the TYPE class addition of the CREATE OBJECT obj statement can be used to create an instance of the class class .
The instance operator NEW enables objects to be created in general expression positions.

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.