ABAP CDS in TechEd Keynote

Bjoern Goerke has shown ABAP CDS in his keynote for TechEd Barcelona, yes, ABAP!

Interestingly, he did not talk much about all the DDL language elements of ABAP CDS. In fact, he used quite a simple CDS view:

/wp-content/uploads/2015/11/cds1_830086.gif

The select statement of the view wraps the access to database table zbg_marsdata. Some of the modeling capapbilities of CDS shine through with the association _MarsSite that joins Z_MarsRoverMissions with Z_MarsSites. But this was of marginal importance for the presentation.

What he did talk about were annotations!

/wp-content/uploads/2015/11/cds2_830096.gif

The DDL source code consists mainly of annotations and not of SQL! What’s that all about?

With annotations, you can semantically enrich your data model. And as you see, this is abundantly done above. Let’s have a look behind the curtain.

What are Annotations?

From the compiler’s point of view, annotations are simply something that can be written at given positions and have to follow a prescribed syntax. As shown in an example of the documentation, you can write something like

@v_annot4:{ annot0, annot1:’abc’, annot2:123 }

into the DDL source of a CDS view. The source is syntactically correct and can be activated. Of course, such an annotation has no meaning as long as nobody evaluates it. During activation of a DDL source, its annotations are saved in system tables and there are system classes available to evaluate them.

Some annotations are evaluated directly during activation and by the ABAP runtime environment.

Annotations before ABAP 7.50

Before ABAP 7.50, only a handful annotations played a role. Those were the annotations that are evaluated during activation and by the ABAP runtime environment. We call those annotations ABAP annotations. They are documented as part of the ABAP CDS documentation, as e.g. the ABAP view annotations. An important example is @ClientDependent, that defines the client handling when Open SQL is used to access a CDS entity. Other examples are the EndUserText annotations that denote translatable texts.

Annotations with ABAP 7.50

The usage of annotations is not restricted to the ABAP Dictionary’s own needs and the ABAP runtime environment (e.g.. Open SQL). As said above, you can enter for annotations what you want, as long as you stay within the syntax rules. Of course, there must be someone who evaluates it. And that’s what software components of SAP do with ABAP 7.50! Software components of SAP such as ODATA, UI, and Analytics prescribe sets of annotations that can be used to achieve a defined behavior and the frameworks themselves provide frameworks that evaluate these framework specific annotations and act accordingly. With other words, it’s not the ABAP runtime environment alone any more that evaluates DDL source codes! Accordingly the documentation of these annotations is not part of the ABAP CDS reference documentation (so don’t send your error messages there …) but delivered by the respective software components. There is a landing page where all SAP annotations are listed and where you find links to the detailed framework documentation.

As you see in the screen shot of Bjoern’s session above, he uses lots of framework specific annotations as @Search… , @UI…. While the syntax coloring and code completion of ADT recognizes them, the ABAP runtime environment (e.g. Open SQL) does not care at all. You have to work with the respective frameworks in order to see the effects! Of course Bjoern did exactly that.

Here is an example for a documentation that describes what you have to do in order to expose a CDS View as OData Service:

Exposing CDS View as OData Service

Have fun!

Note

Please note that SAP currently does not recommend to create customer annotations, At the moment you should work with SAP annotations (ABAP annotations and framework specific annotations) only.

PS: Sorry for the blurred screen shots, but they are taken from the TechEd video.



To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. Oliver Jaegle

    From my point of view, annotations are just a textual representation of metadata. As you wrote it’s up to a consumer to interpret this and since everybody (partners, customers) are able to specify their own (if I got you right), custom annotations in (stacked) CDS-views could in future be used as artifacts for customer specific frameworks. I like that idea.

    Two questions however immediately pop into my mind:

    • Is there a namespace-concept for annotations? What about potential collisions?
    • On activation, the change would have to be communicated to all potential consumers. Is there a BAdI or similar which gets passed the changes? Always analyzing the complete state wich CL_DD_DDL_ANNOTATION_SERVICE=>GET_ANNOTATIONS does not sound promising to me, as each consumer might be only interested in a particular set of annotations.

    Apart from these questions, I’m not happy at all with the set of SAP annotations and how they are being used in a common CDS-view. I blogged about that here. However, I did not get any response dealing with my concerns by someone who has more experience with that (some SAPian). Is there any volunteer around?

    Cheers,

    Oliver

    (0) 
    1. Horst Keller Post author

      Is there a namespace-concept for annotations? What about potential collisions?

      That’s why I have added

      Please note that SAP currently does not recommend to create customer annotations, At the moment you should work with SAP annotations (ABAP annotations and component annotations) only.


      😏


      A possible solution – and as far as I know, HANA CDS does that – would be to define the allowed annotations as transportable repository objects. There is already a spec for a definition syntax that could be used in DDL source codes for annotation definitions. Then only defined annotations could be used in CDS entities. In the annotation documentation you even see that syntax but, alas, it cannot be used in ABAP CDS currently. Then the ABAP runtime could even carry out basic checks for all annotations, not only the ABAP annotations … (that’s my personal view of the things).


      • On activation, the change would have to be communicated to all potential consumers. Is there a BAdI or similar which gets passed the changes? Always analyzing the complete state wichCL_DD_DDL_ANNOTATION_SERVICE=>GET_ANNOTATIONS does not sound promising to me, as each consumer might be only interested in a particular set of annotations.

      I guess that for that, the same as above could help.


      Apart from these questions, I’m not happy at all with the set of SAP annotations and how they are being used in a common CDS-view. I blogged about that here. However, I did not get any response dealing with my concerns by someone who has more experience with that (some SAPian). Is there any volunteer around?


      not I (remember, I’m only the ABAP language docu writer …)


      (0) 
      1. Oliver Jaegle

        If custom annotations are not … intended due to the limitations mentioned, you might want to revise

        As said above, you can enter for annotations what you want, as long as you stay within the syntax rules.

        I like the idea with the transportable annotations. However, even then a detailed change notification would be useful.

        Is the API which is called on activation published?

        (0) 
          1. Oliver Jaegle

            [quote] no, that’s the situation. [/quote]


            Expected that, therefore wrote “might”. From a documentation point of view I’m fine with that. Guess you wanted to express that there’s (currently) no checking of the annotation’s value.

            (0) 

Leave a Reply