Skip to Content

Real life examples & use cases for ABAP 740 and CDS views

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


Data 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


Value operator


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.

You must be Logged on to comment or reply to a post.
  • What i don't like having Inline declarations is that they are still valid after their declaration. In your example with the loop i would be happy if the field symbol is no longer valid after the corresponding endloop.

    As we are upgrading our system right now I'm still thinking about how to handle this in our development guidelines. Currently I tend to forbid them.

    • It can be problematic if it is written directly in a program, but inside a modularization blog it will be a local definition and won't be available globally so if modularization blocks are small it would not be a problem in my opinion.

        • Rainer Hübenthal wrote:

          Yes. Currently its the same as DATA declariations somewhere in the sourcecode. Forbidden here.

          I respectfully tend to disagree here.

          What is the point of declaring everything at the beginning? Does it give the developer any advantage (maybe in old ABAP releases it did)?  One can easily navigate to the variable declaration, wherever it is defined.

          If one declares the variable just before using it, it'll save the trouble of navigating to the declararation section, since the variable is in your line-of-sight.

          Having said that, i still don't like data declarations inside iterations (LOOP..ENDLOOP, DO..ENDDO etc.). But that's just a personal preference!

          • Wheres the trouble of navigating when you can jump forward or backward as you said? I still cant see any advantage of having data declaration spreaded in the source code, for me its a kind of laziness not thinking and planning before.

          • As I said,  I tend ... so currently I'm looking for pros and cons. If these declarations were only local to the defining block  I would have less concerns, but they can be a global definition and therefore they can be a reason against maintainability

          • If these declarations were only local to the defining block  I would have less concerns

            I agree with you on this one though. Developer discretion is highly advised 😛

            But if i am on ABAP 740 & someone says, "Inline declarations, sorry, no can do!" ... That someone is going to have a very bad day! 😆

          • Well as I'm responsible for the guidelines in my company I cant see having a bad day caused by an developer as the code checking is done automatically and there's no way to release a transport having mandatory issues in the code profiler 🙂

            But may be there's a better place to discuss this? Don't want to spoil this blog and our discussions tend more and more to shift away from the topic.

  • Hello Gungor,

    I would highlight the ability to write shorter, expressive code using internal table operators in 7.4. Cf both version of YY_SATRA_INCLUDE, 6200 LoC vs. 4600 LoC, e.g.

      METHOD lif_actors~lifelines.

        rt_lifeline = CORRESPONDING #( mt_actor ).


      METHOD lif_actors~lifelines.

        DATA ls_actor TYPE ts_actor.

        CLEAR rt_lifeline.

        LOOP AT mt_actor INTO ls_actor.

          INSERT ls_actor-lifeline INTO TABLE rt_lifeline.



    This cache implementation either reads from the internal table or queries the database, fills the internal table and returns the value:

      METHOD is_global.

        rv_flag = VALUE #( mt_class[ name = iv_name ]-global

          DEFAULT fetch_is_global( iv_name ) ).


      METHOD fetch_is_global.

        CLEAR rv_flag.

        SELECT SINGLE 'X' FROM tadir INTO @rv_flag 

          WHERE pgmid = 'R3TR'

          AND   object = 'CLAS'

          AND   obj_name = @iv_name.

    *   add to cache proxy for table TADIR

        INSERT VALUE #( name = iv_name

                        global = rv_flag ) INTO TABLE mt_class.


    As you pointed out, features are added incrementally to the ABAP stack, but real life code has to support older releases. You might have to work with CONCATENATEs, i.e. without string templates 🙁 . And there is always the risk to reduce quality.

    Have fun!


  • Hello Güngör,

    We are using ECC 6.0.

    I think, ABAP 7.40 is not valid ECC 6.0 ?

    Right ?

    Is there any  relation Enhancement Package ?



  • Hi Ahmet,

    Thank you for the article.

    Please help me out in understanding - So if I have to create data models in HANA, we have 2 options -

    1. Calculation Views
    2. HANA CDS views (I am not talking about the ABAP CDS here

    So are you saying that whenever we have scenarios where the ABAP layer needs to read these views, we would use CDS as our strategy?

    ANd by implication, if we have no ABAP layer and only native HANA, we just go along creating calculation views.

    Am I correct?