It has been long time since I post my previous blog which draw more attention than I expected and I was thinking what could be next. Luckily I am working on a S4HANA project and having opportunity to try new syntax options and I will compile some real life examples and test samples about new syntax options and CDS views and try to explain why and how they are useful and we should try to use them.
First of all it is possible to get information about all of them in ABAP keyword documentation in Release specific changes as shown below. There are many changes, in my blog I will only briefly mention the ones that I had opportunity to use.
Some of the examples was only created to see what can be done, as they may not fully fit to a business case.
Release specific changes branch in keyword documentation
1. Inline declarations
Field symbol with inline declaration
I only code in ABAP for a long time and I can say it is really nice to avoid necessity of going top of the block just to define something so using inline declarations is really practical and time saving.
2. Constructor expressions ( Thanks to Ahmet Yasin Aydın )
Constructor expression new
It is again time saving have better readability and helps us to have shorter source codes, no need to say there can be countless different usage options.
3. Rule changes for joins
Above statements is directly from ABAP keyword documentation which will allow us to build more complex join statements, we can now use only restriction from another left side table and we can use fields from left side table in where condition which is quite revolutionary and it is possible to build one big select statement which means some reports can now only built using one select statement by also help of other changes (using literals, case and more) that can be seen in keyword documentation. I did verify it and coded some reports in both logic and compared the results it is simpler to code and faster in HANA Here comes the example.
Also restriction to use only equality comparison on “On condition” is removed for outer joins.
Excluded the field list for the below select since it was really a big one
Joins ( some of the tables may better be connected using inner join just created to test left outer joins )
Where condition also contains fields from left side tables:
4. Source codes that can only be edited in Eclipse( ADT )
This one is not a syntax option but it is something that we need to know so I wanted to add this to my list. Eclipse is in place for a long time but so far we were able to edit every development object in Eclipse or in SAP GUI (Correct me if I am wrong ) but it is changed, now there are CDS ciews and AMDP (Abap Managed Database Procedures) that can only be edited in Eclipse. So if for any reason you need to develop these objects you also need to have Eclipse in your PC and it may be nice to start coding in Eclipse if you have not started yet.
Message if we try to edit AMDP in GUI:
Eclipse edit display:
5. CDS Views
After HANA we had different tools like Analytical and Calculation views and external view, database procedure proxies to read these views directly from ABAP but there are some practical difficulties to use them if most of the development tasks in a project is handled by ABAP programmers (learning SQL script, granting project team members authorization in DB level and having different level of transport management which can easily cause problems), CDS views can be a good alternative they are at least managed in application layer and have same transport procedure as older abap development objects.
We keep searching use cases for the CDS’s in our project. We so far created master data views and tried to create some reusable CDS views which can be used by several reports can be seen below.
We also tried to convert some old logic ( Select data from different tables and merge them inside loops) into CDS’s its performance is better but could not test with some really big data yet but I also need to mention it is at the same level of performance with a big select shown in Open SQL explained in point 3 .
Example view on material data, it can be used in select statements in ABAP or viewed in SE16
6. CDS Union all example
This helped us to simplify a case: There are different price tables with different structures and several reports needs to read price data. We designed one big structure with necessary fields from different tables, now we can use this one view instead of 5 different tables wherever we need to read price data. I am only adding first two tables but 3 more table is added with union all and all can read at once now.
Result for the view
There are many other changes to explore for some it may take long time to have a proper case to apply, would be happy to know if you also used some new syntax changes and how they made life easier for you.