NEW Operator – Single Value for All Data Types
ABAP is a new operator single value. We shown in the last post that one of the enhanced features in EhP7 is NEW Administrator. In this case, NEW Operator – Single Value for All Data Types or NEW Administrator – Single Incentive for All Information Types would be used.
NEW Operator: One Value for All Data Types for the New Administrator
you can also read for:- list of data types in sap abap
I) At any one time, an articulation that has been identified for an information item may either contain or be a constructor articulation.
ii) When a constructor articulation is doled out to a reference variable utilizing NEW, this variable focuses to the underlying item all along. This implies that the first reference is as of now not accessible involving the objective variable in the articulation.
* Example 1 PARAMETERS input(10) TYPE c DEFAULT 'EhP7'. DATA d_ref TYPE REF TO string. d_ref = NEW string( 'Welcome' && ` ` && input ). WRITE:/ d_ref->*.
NEW operator constructs an anonymous data object of the type string, whose value is determined using a string expression.
Note: The chaining operator && concatenates two operands in a string expression as a character string.
* Example 2 TYPES: BEGIN OF ty_marc, matnr TYPE matnr, werks TYPE werks_d, END OF ty_marc. DATA: d_ref TYPE STANDARD TABLE OF REF TO ty_marc, wa_marc TYPE ty_marc. SELECT SINGLE matnr werks FROM marc INTO wa_marc. APPEND wa_marc TO d_ref. " Syntax Error
The above statement APPEND wa_marc to d_ref would give syntax error: “WA_MARC” cannot be converted to the line type of “D_REF”.
Instead if we use the NEW Operator as shown below, the content of the work area can be assigned to the data object d_ref.
APPEND NEW #( wa_marc ) TO d_ref.
Following the SELECT, a structured, enigmatic information object is created for the selected column. This information object receives the line’s substance. The article is written in the assertion’s general articulation position. Simply attach the NEW information reference to an inner table using the appropriate column type. A table referencing mostly new, enigmatic information objects is the result.
As mentioned in a previous post, the article reference on the left-hand side determines the sort when “#” comes after NEW.
These are basic models. In resulting posts, we would attempt to investigate more perplexing and genuine undertaking situations. Kindly look at the following post on structures and inner tables in NEW Administrator.
YOU MAY LIKE THIS