Generating Objects

This section describes the generation of data objects and objects in the ABAP Objects language. Generating an object or data object is equivalent to the dynamic generation of an instance of a data type or a class. While instances of classes can only be generated as described in this section, instances of data types (data objects) that are declared with the statement DATA, or related statements, such as CONSTANTS, are generated automatically when their context is loaded into the internal session. Dynamic generation of data objects is only necessary if the data type is only recognized for the first time during program execution, or if you want large amounts of memory to be consumed only for short periods of time.

Data objects and objects are generated by default in the internal session of the current program, and only programs of the same internal session can access them. As of release 6.40, you can also generate shared objects in the shared memory.

Dynamically generated objects can only be addressed using reference variables, and can be deleted from the internal session by the Garbage Collector if they are no longer referenced.

There are two statements for generating objects: