Skip to Content

Hi!

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!

To report this post you need to login first.

5 Comments

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

  1. Ceyhun Alp

    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
    key ekpo.ebeln,
    key ekpo.ebelp,
    key _rseg.belnr,
    key _rseg.gjahr,
    key _rseg.buzei,
    --ekpo   
        ekpo.menge as menge_ekpo,
        ekpo.netwr as netwr,
        ekpo.meins,
    --rseg 
        _rseg.matnr,
        _rseg.wrbtr,
         _rseg.menge,
    //--rbkp
        _rbkp.lifnr,
    --Association  
        _lfm1,
        _rbkp,
        _rseg
    }

    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,

    Ceyhun

     

    (0) 
    1. Maksim Alyapyshev Post author

      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.

       

      (1) 
  2. sathish reddy

    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

    (0) 
    1. Maksim Alyapyshev Post author

      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.

      (0) 
  3. Kateryna Plokhikh

    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,

    Kateryna

     

    (0) 

Leave a Reply