According to SAP news, SAP Enhancement Package 7 for SAP ERP 6.0 contains more than 750 business functions. The key new features are SAP Fiori, MRP runs, and data aging objects. EhP7 is the first enhancement package to be optimized for both the SAP HANA database and the traditional certified databases.

[adToAppearHere]

As a hardcore ABAP developer, I was curious to know, how is an ABAPer affected by this upgrade 7.4. After exploring the system and going through the sap release documents, I have tried to jot down the changes which ABAPers like me would be interested in. 🙂

And NEW and VALUE Operators are the first features in EhP7 which the ABAPer would be using regularly.

NEW – Instance Operator

i) NEW – Initial Value for All Types

ii) NEW – Single Value for All Data Types

iii) NEW – Structures

iv) NEW – Internal Tables

v) NEW – Classes

VALUE – Value Operator

i) VALUE – Initial Value for All Types

ii) VALUE – Structures

iii) VALUE – Internal Tables

In this post, I would like to show some usage of NEW Operators for Initial Value for All Types.

1 2 3 4 5 6 7 8 9 * Type declaration TYPES : BEGIN OF ty _ marc , matnr TYPE matnr , werks TYPE werks _ d , END OF ty _ marc . * Type Ref To DATA o _ ref TYPE REF TO ty _ marc .

1 2 3 4 5 6 7 8 9 10 11 * Example 1 * Instantiate the object o _ ref = NEW ty_marc ( ) . * Usage demo SELECT SINGLE matnr werks FROM marc INTO o _ ref - > * . IF sy - subrc EQ 0. * Displaying the fields as we used to do earlier WRITE : / o _ ref - > * - matnr , o _ ref - > * - werks . ENDIF .

Please note NEW <TYPE>( ) is the syntax to instantiate any object.

1 2 3 4 5 6 7 8 9 10 11 * Example 2 * Instantiate the object using # o _ ref = NEW # ( ) . * Usage demo SELECT SINGLE matnr werks FROM marc INTO o _ ref - > * . IF sy - subrc EQ 0. * Displaying the fields as we used to do earlier WRITE : / o _ ref - > * - matnr , o _ ref - > * - werks . ENDIF .

Please note NEW # ( ). When “#” succeeds NEW, it means the object ref in the Left Hand Side determines the type.

This is a small post to make you aware of the new syntax. Both above constructor expressions have the same function. I will post more on NEW and VALUE operators in subsequent posts.

If you are already in EPH7, you might like to check some excellent posts by Naimesh on EHP740 with examples of OOPs.

Oops!! Before I sign off, are you wondering how the output would look like.. 🙂 .. Nothing new. Output is same as before EhP7.. No upgrade in output display.. 😛

Please check our next post NEW Operators – Single Value for all Data Types.

If you want to get notification about the newest posts, please subscribe. Your email is safe with us.

If you liked it, please share it! Thanks!

Image source: via Free Stock Photos foter.com