Skip to Content

Standard DEMO Examples of ABAP CDS views


This post was created to show standard ABAP development package with could be very useful for:

  • ABAP programmers starting  to use CDS views functionality
  • Application consultants (e.i. in case of customer CDS views enhancements should be done or some standard CDS view results don’t seem to be correct)

You could find a package SABAPDEMOS in HANA Studio ABAP perspective in case of S/4HANA system (or in SE80 t-code). There are a lot of useful things there.

In Core Data Services group you could find examples of:

  • Usage of different annotations in CDS views
  • CDS view based on Table function
  • CDS view with parameters
  • CDS views with different types of joins, union and associations
  • CDS view with currency conversion and unit conversion
  • Usage of SQL functions like numeric, string, date/time functions in CDS views
  • Authorization check in CDS view and definition of Access Control using DCL
  • Extension examples of CDS views

This list depends on NW version of your system, because some features like extension of CDS view with aggregate functions or union was not available before NW 7.51. This is a good post were you could find more detailed information about  CDS ABAP Features.

List of available CDS examples of NW 7.51 SP00 is shown below:

Unfortunatly, I didn’t find there any examples of demonstration of hierarchy usage in CDS views. If you are interested in this case you see may post “How to build a Custom Hierarchy in ABAP CDS views”.

Also I couldn’t found examples of CDS views for analytical reporting purposes.

However this is great resource for learning by examples!


Thank you for attention!

You must be Logged on to comment or reply to a post.
  • Hello Maksim,

    First of all, thank you for those all great posts. Very helpful..

    I am trying to build an analytical model and a query than, using ekpo, rseg, rbkp and lfm1 tables.

    When i try to use the fields of the 2nd association to make a newer 3rd association, things go worse.I get the error “Association _xxxx cannot be used locally within the view.” If I don’t use this association locally, I can’t make the relation through the lfm1 table.

    Here is the error message;

    Here is my cds.

    @AbapCatalog.sqlViewName: 'ZahmmDDL006I2'
    @Analytics.dataCategory: #FACT
    @VDM.viewType: #BASIC
    @EndUserText.label: 'Demo'
    define view Zahmm_DDL006_I2 as select from ekpo
    association to rseg as _rseg
     on ekpo.ebeln = _rseg.ebeln and
        ekpo.ebelp = _rseg.ebelp
    association to rbkp as _rbkp
    on $projection.belnr = _rbkp.belnr and
       $projection.gjahr = _rbkp.gjahr
    association to lfm1 as _lfm1
    on $projection.lifnr = _lfm1.lifnr   
    key ekpo.ebeln,
    key ekpo.ebelp,
    key _rseg.belnr,
    key _rseg.gjahr,
    key _rseg.buzei,
        ekpo.menge as menge_ekpo,
        ekpo.netwr as netwr,

    I am not sure if associations have some other use cases but not for this. When I do the same logic with traditional join, it works as expected. Do i need to use join? If so, do you have a best practice advice when to use join and when to use association?

    Thank you and regards,



    • Hello!

      In common associations are useful if you need to get some fields in upper ABAP CDS view, e.i. in case of star schema model fact with dimensions. In some cases fields from association table aren't needed and join willn't performed.

      In your case I think normal joins could be used, because a join must be executed to get data from lfm1 table.

      You could also try to see standard ABAP CDS view for Purchase Orders I_PurchaseOrder, I_PurcahseOrderItem to use them as templates.


  • Hi Maksim Alyapyshev,

    I've a doubt in Basic view..


    I created the Basic view like this. If I keep data category as dimension, view is executing. if i keep data category is cube, then also it is executing successfully. then what is the difference between dimension and cube in basic view

    • Hi!

      Annotation @Analytics.dataCategory: ‘<Value>’

      • By specifying the data category, the developer can give directives and hints to the analytics manager on how to interpret individual entities.
      • Possible values: #DIMENSION, #FACT, #CUBE or #AGGREGATIONLEVEL.

      Consider what category of data you are going to select in view.

      • If there are master data: attributes, text, hierarchies – use #DIMENTION category.
      • If there are transactional data – use #FACT or #CUBE type. In #CUBE you could add associations to #DIMENTIONS, describing you transactional data. For transactional data category you always have some key figures and should describe how to aggregate this data (sum, max, min, avg etc.). In comparison for #DIMENTION category it isn’t needed and possible.

      More details in documentation.

  • Hi Maksim,

    Very useful post. I have a question about usage parameters in associations.

    We would like to use parameters in composite view which has associations to some basic views. How can we pass parameters to associations (we want to get all fields from our associations)?

    Unfortunately I didn't find any example in demo's.

    Thanks in advance for your help.


    Kind regards,



    • Hi,


      You do that in brackets, e.g.

      as select from Z_I_FIGL_PlanAndActual (P_CurrentYear:$parameters.P_CurrentYear, P_PreviousYear:$parameters.P_PreviousYear, P_PreviousFiscalPeriod:$parameters.P_PreviousFiscalPeriod)

    WHERE WERKS ‘2000’
    AND BWART ‘101’
    AND DMBTR <> 0  .

    WHERE WERKS ‘2000’
    AND BWART ‘561’
    AND DMBTR <> 0.

    *        RSEG, RBKP
    WHERE WERKS ‘2000’
    AND WRBTR <> 0.

    WHERE WERKS ‘2000’
    AND BWART ‘101’
    AND DMBTR <> 0.


    how to cds



  • Hi Maksim,


    This is quite a good stuff. I am actually a beginner to CDS view, I see different types of view and lot things going on with ABAP on HANA.

    I was wondering what is the road map(concepts in order) that we need to actually focus on to become good at CDS views( basics to complex) .


    Thanks in advance.


  • Hi Maksim


    Thanks for this post. Very useful.

    Where can we find list of ABAP CDS Views which can be used for BW Extraction. E.g. In BW, there is standard Data Source 2LIS_11_VAITM, so what will be the corresponding ABAP CDS View for this Data source.