ABAP Keyword Documentation → ABAP - Reference → Creating Objects → CREATE OBJECT
CREATE OBJECT - TYPE
Other versions: 7.31 | 7.40 | 7.54
Syntax
CREATE OBJECT oref [area_handle]
TYPE { class
[parameter_list] }
| { (name) [parameter_list|parameter_tables] }.
Effect
For class
you can specify any
concrete class that is more
specific than or identical to the static type of the object reference variable oref
.
oref
can be a class reference variable or an interface reference variable. An instance of the specified class class
is created.
As an alternative to the direct specification, you can use name
to specify
a character-type data object that contains the name of the class in uppercase when the statement is executed. The name of the class in name
can also be an
absolute type name.
Note
When dynamically specify the class, the parameters can either be specified statically in
parameter_list
or dynamically in parameter_tables
.
Example
Generation of an instance of a class c1
through explicit reference to the
class. The static type of the reference variable is the root class object
and therefore more general than any other class.
CLASS c1 DEFINITION.
...
ENDCLASS.
...
DATA oref TYPE REF TO object.
...
CREATE OBJECT oref TYPE c1.