Skip to Content

A Programming Model for Business Applications (7) Epilog: What is New in HANA SPS9

Today, I would like to add an epilog to my “programming model” article series on the SAP HANA SPS9 update (start: A Programming Model for Business Applications (1): Assumptions, Building Blocks, and Example App). In my article, A Programming Model for Business Applications (2): Implementing the Entity Model with CDS I listed a couple of CDS restrictions that blocked me from writing down my data model in a compact format. Some of these limitations have been removed, in particular:

  1. It is now possible use CDS entities and views from other files.
  2. CDS supports “unmanaged associations” (= ability to define an association on existing elements using “on”)
  3. CDS supports “ad-hoc associations” in views
  4. CDS supports “anonymous structures” in entities

Let me now give some examples on how to use these features in the context of my example application.

1. Referencing CDS entities and views from other files

I think this is quite obvious. Here is an example:

namespace XYZ;

using XYZ::common as common; // SP9_NEW

using XYZ::address as address;

using XYZ::businesspartner as businesspartner;

@Schema: XYZ

context salesorder {



Note: The “using” statement works like an import, in my example for the named contexts.

2.“Unmanaged Associations”

Unmanaged associations are useful to define the relation between parent and child in a business object.


entity SalesOrder {

    key ID_    : Integer64;

  Item       : association [0..*] to salesorder.Item  on Item.Parent_ID_ = ID_; // SP9_NEW



entity Item {

  key ID_     : Integer64;

Parent_ID_  : Integer64;

Parent      : association [1] to SalesOrder on Parent.ID_ = Parent_ID_; // SP9_NEW



I also use them to define time-dependent associations, for example the time-dependent elements (for example name, etc.) of a business partner:

  CurrentCommon   : association [0..1] to businesspartner.Common   on CurrentCommon.Parent_ID_= ID_

                                      and CurrentCommon.ValidityPeriod.StartDate< now() and CurrentCommon.ValidityPeriod.EndDate> now();

3. “Ad-hoc Associations” in Views

With ad-hoc associations in views I can use calculated elements from other views, for example here:

First, I calculate the net amount of an item in  a sales order as:

  view “Item$C” as select from Item {




      (ListPriceAmount* Quantity) * (100 DiscountPercent) / 100 as “NetAmountValue”,



Second, I calculate the total net amount of the sales order as:

   view “SalesOrder$C” as select from SalesOrder

        mixin { // SP9_NEW

        _Item : association to “Item$C” on _Item.Parent_ID_ = ID_;

      } into




         sum(_Item.NetAmountValue)  as “NetAmountValue”,



      group by ID_, <…> ;

4. Anonymous Structures

This is a “nice to have” feature, it helps me to get rid of the “type” definitions for data structures that are only used once, for example here:

  entity SalesOrder {


    Status {

     LifeCycleStatus             : association [0..1] to salesorder.LifeCycleStatus;

     InvoiceProcessingStatus     : association [0..1] to salesorder.InvoiceProcessingStatus;

     CreditWorthinessStatus      : association [0..1] to common.CreditWorthinessStatus;


As a summary: I can now get rid of my hdbview-Files that I needed in SPS8 because of the CDS limitations. This makes the data model much more readable.

If you want to get an overview on new SPS 09 developer features, you can read the following article: SAP HANA SPS 09: New Developer Features

You must be Logged on to comment or reply to a post.
  • Hi Thomas,

    Can you just brief the use case for when to use CDS. Many times it feels perfect to use the conventional way of defining views and tables.

    So the question 'why CDS?' always confuses.

    Everywhere we could find the explanation and definitions for CDS but exactly why was it developed remains unclear.

    It would be really helpful if you could share your thoughts!

    Thanks & Regards,


    • Hi Monissha,

      SAP positiones CDS as the strategic language for defining tables and views (in "native" HANA, but also in ABAP). So the strategic answer is: use CDS instead of the conventional way.

      The first advantage (and reason) is obvious: the code of your data mode is much smarter with CDS.

      The second advantage is that SAP will provide additional services and features on top of CDS. One example if the the JavaScript API described here: SAP HANA SPS 09: New Developer Features; XSDS (XS Data Services) taht makes also the JavaScript coding smarter.

      Unfortunately the adoption speed is not that high as I would like it. For example in odata I would like to use CDS entities and views and expose the assoications defined in CDS as navigation properties (instead of defining them again a second time, see the example in my article A Programming Model for Business Applications (4) Service Adaptation and UI (Read Service) . But we will see more and more features based on CDS.

      The pragmatic question is: change to CDS now? In SPS8 I found a lot of limitations in CDS for views, so that I would recommend to model the database table with CDS only. In SPS9 I was able to define all the views in my data model with CDS.

      Best regards,



      • >For example in odata I would like to use CDS entities and views and expose the assoications defined in CDS as navigation properties (instead of defining them again a second time

        I would state that SAP is quite aware of that missing piece and we've already had discussions and design work on merging CDS and XSOData allowing the reuse of the entity and association definitions. I can't state when this functionality might come, but it is something which work has already begun.

  • Hi Thomas,

    do you know if there is any official documentation for "ad-hoc associations in views"? It's neither mentioned in the current CDS Reference Guide (SPS 10) nor in the SCN article describing new CDS features in SPS 9. The only reference seems to be in the hdbdd file template for views and in this article.

    Since this sounds like a mighty instrument, I find it confusing that there is so little mention of it.

    Best regards