SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Creating Objects and Values → NEW - Instance Operator →NEW - Single Value for All Data Types
Syntax
... NEW dtype|#( dobj ) ...
Effect
If dtype is a non-generic elementary data type, a structured type, a table type, or a reference type or # represents a type like this, a single data object dobj can be specified as a unnamed argument, of the type dtype or convertible to this type. dobj is a general expression position. The value of dobj is assigned to the new anonymous data object. The assignment is made in accordance with the applicable assignment rules.
Note
In particular, an expression specified for dobj can itself be a constructor expression or contain a constructor expression.
Example
Constructs an anonymous data object of the type string, whose value is determined using a string expression.
PARAMETERS input TYPE c LENGTH 10 LOWER CASE DEFAULT 'World'.
DATA dref TYPE REF TO string.
dref = NEW string( `Hello ` && ` ` && input && `!` ).
MESSAGE dref->* TYPE 'I'.
Example
For each row read, a structured anonymous data object is created in a SELECT loop. The content of the row is assigned to this data object. The object is created in the general expression position of the statement APPEND and the new data reference is appended directly to an internal table with the appropriate row type. The result is a table that references all new anonymous data objects.
DATA dref_tab LIKE TABLE OF REF TO t100 WITH EMPTY KEY.
DATA wa TYPE t100.
SELECT *
FROM t100
INTO wa
WHERE sprsl = sy-langu.
APPEND NEW #( wa ) TO dref_tab.
ENDSELECT.