Ansicht
Dokumentation

ABENCREATE_OBJECTS - CREATE OBJECTS

ABENCREATE_OBJECTS - CREATE OBJECTS

ABAP Short Reference   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book

Creating Objects and Values

This section describes how data objects and instances of classes are created and values constructed.

Creating Objects

Creating an object or data object is equivalent to the dynamic creation of an instance of a data type or a class. While instances of classes can only be created as described in this section, instances of data types, that is data objects, declared using the statement DATA, or related statements such as CONSTANTS, are created automatically as named data objects when their context is loaded into the internal session. Data objects only need to be created dynamically if the data type is only known when the program is executed, or if large amounts of memory are only to be used for short periods of time.

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

Objects can be created using one of the following:

  • The addition NEW in the INTO clause of for the implicit creation of data objects as target areas.

Data objects and objects are created in the internal session of the current program by default, and only programs in the same internal session can access them. The following, however, can also be created:

Note

The statement ASSIGN LOCAL COPY is used for an obsolete form of object creation.

Constructing Values

The attribute values of a newly created instance of a class can be constructed using the instance constructor of the class. The input parameters of the instance constructor can be filled using the EXPORTING addition of the statement CREATE OBJECT or using actual parameters for the instance operator NEW.

The values of dynamically created or statically declared data objects can be constructed using the following constructor expressions:

  • When anonymous data objects are created dynamically using the instance operator NEW, values for all data types, particularly structured and tabular types, can be constructed and assigned to the created data object.
  • The value operator VALUE can also be used to construct the content of complex data objects (structures, internal tables) and thus exceeds the functionality of the VALUE addition.

Note

Like any constructor expression, the value operator VALUE can be used in general expression positions and in functional operand positions, including particularly the right side of an assignment to an inline declaration.

Example

Inline declarations of a reference variable dref and a structured variable dobj. The instance operator NEW creates an anonymous data object that is referred to by dref. Using functional method calls, the instance operator NEW and the value operator VALUE are used to construct and assign values for the components of the structures.

DATA(dref) = NEW struct( col1 = meth->get_col1( )
                         col2 = meth->get_col1( ) ).

DATA(dobj) = VALUE struct( col1 = meth->get_col1( )
                           col2 = meth->get_col1( ) ).






ROGBILLS - Synchronize billing plans   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.

Length: 6346 Date: 20240425 Time: 124037     sap01-206 ( 88 ms )