ABAP - Keyword Documentation →  ABAP - Reference →  Creating Objects and Values → 

NEW - Instance Operator


... NEW type( ... ) ...


A constructor expression with the instance operator NEW creates an anonymous data object or an instance of a class. The result is a reference variable that points to the new object. The following can be specified for type:

The same descriptions apply as for the CREATE statements. Once an object has been created, it is provided with values using the parameters in parentheses. The syntax used in pass by parameter depends on the type used. There are specialized categories of pass by parameter for complex types.

When a constructor expression is assigned to a reference variable using NEW, the information in the parentheses is evaluated before the new object is bound to the target variable.

Return Value

If an instance of a class is created successfully, the instance operator NEW sets sy-subrc to 0. Non-class-based exceptions of the instance constructor cannot be handled, which means that sy-subrc is never set to a value other than 0. The return code sy-subrc is not set when anonymous data objects are created.



Creates an anonymous data object of the type i with the value 555 and an instance of a local class cls (derived implicitly from the static type of oref). In this case, the last statement can be written just as explicitly as oref = NEW cls( ) or with inline declaration instead of the previous DATA statement as DATA(oref) = NEW cls( ).


DATA: dref TYPE REF TO data,
      oref TYPE REF TO cls.

dref = NEW i( 555 ).
oref = NEW #( ).

NEW - Initial Value for All Types
NEW - Single Value for All Data Types
NEW - Structures
NEW - Internal Tables
NEW - Classes