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

ABAP for SAP HANA. ALV Report On SAP HANA – Opportunities And Challenges

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

  • Related Posts

    SAP ABAP Best Coding Practices for Freshers

    Many freshers start learning SAP ABAP by writing small reports and programs.But when they join real projects, they quickly realize that companies do not only look for working code. They…

    Most Common SAP ABAP Mistakes Beginners Make

    Starting a career as an SAP ABAP developer is exciting, but the early phase is also full of hidden risks. Many beginners focus only on learning syntax and writing programs…

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You Missed

    SAP ABAP Best Coding Practices for Freshers

    • By Varad
    • April 27, 2026
    • 266 views
    SAP ABAP Best Coding Practices for Freshers

    Most Common SAP ABAP Mistakes Beginners Make

    • By Varad
    • April 26, 2026
    • 231 views
    Most Common SAP ABAP Mistakes Beginners Make

    SAP Automation vs Manual Testing: Career Comparison

    • By Varad
    • April 25, 2026
    • 255 views
    SAP Automation vs Manual Testing: Career Comparison

    Can ChatGPT Help in Learning SAP ABAP

    • By Varad
    • April 24, 2026
    • 167 views
    Can ChatGPT Help in Learning SAP ABAP

    How to Build a Business Case for SAP Automation ROI

    • By Varad
    • April 23, 2026
    • 427 views
    How to Build a Business Case for SAP Automation ROI

    External Debugging of an Application of another SAP User in another Location in another Machine/System

    • By Varad
    • April 12, 2026
    • 95 views
    External Debugging of an Application of another SAP User in another Location in another Machine/System