ABAP Keyword Documentation → ABAP − Reference → Creating Objects and Values → CREATE OBJECT
CREATE OBJECT oref
Other versions: 7.31 | 7.40 | 7.54
Syntax
CREATE OBJECT oref [
area_handle] [
parameter_list].
Effect
If the addition TYPE
is not specified, the object reference variable
oref must be a class reference variable. An instance of the class is created that is the static type of the object reference variable. The static type of the class reference variable cannot be an
abstract class, and in particular must not be the root class object
.
Note
When the character #
is used in an operand position with the operand type of a class reference variable, the
instance operator
NEW
works like the statement CREATE DATA dref
.
Example
Creates an instance of a class cls
using an implicit reference to the static type of the reference variables.
CLASS cls DEFINITION.
PUBLIC SECTION.
DATA attr type string VALUE 'Object'.
ENDCLASS.
DATA oref TYPE REF TO cls.
CREATE OBJECT oref.
cl_demo_output=>display( oref->attr ).