NEW Operator – Single Value for All Data Types

NEW Operator – Single Value for All Data Types

In the past post, we showed that NEW Administrator is one of the improved elements in EhP7. Here, we would see the use of NEW Administrator for Single Incentive for All Information Types or NEW Operator – Single Value for All Data Types.

For NEW Administrator: NEW Operator – Single Value for All Data Types

I) An articulation determined for information item might itself at any point be a constructor articulation or contain 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.

For column chose, an organized mysterious information object is made after the SELECT . The substance of the line is doled out to this information object. The article is made in the overall articulation position of the assertion Attach and the NEW information reference is affixed straightforwardly to an inward table with the fitting column type. The outcome is a table that references generally new mysterious information objects.

Currently referenced in past post, when “#” succeeds NEW, it implies the article ref in the Left Hand Side decides the sort.

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

SAP FICO Demand In India

SAP FICO as a Career

Proxy in SAP Abap: Seamless Communication

 

 

WhatsApp WhatsApp us