Skip to Content
Technical Articles

Part#10. CDS Views – @VDM Annotation

Before we start developing any CDS view, it is highly important to understand the purpose of it.  Why it is being created? Who and where this CDS view is going to be consumed – Is it for Analytics tools? Is it for FIORI app? Is it just to be consumed by other CDS views?  Once we understand all these elements, it would help to standardize the view development and that’s when we can define the specific Annotations within the view.  We must apply the annotations which make sense to the CDS view.  Though adding annotations which are not required may not impact anything but would surely make it confusing when other developers or project support team will deal with those views.

At a glance below type of Annotations are used while configuring CDS views;

-@OData, @UI – Used for FIORI applications.

-@Analytics – Used to consume CDS view into Analytical tools like Bex, Lumira, Webi, Analysis for Office.

-@ObjectModel – Used for Transactional applications using BOPF

-@Semantics – Used for S4HANA Embedded Analytics

You can find detailed information on all type of Annotations here; https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/7.5.9/en-US/630ce9b386b84e80bfade96779fbaeec.html

 

@VDM:

To standardize the CDS view technical development, SAP came up with the Best Practices with @VDM annotation. This is to standardize the development process and if religiously followed in the organization, it will very easy to maintain these technical artifacts with no issues and confusions.  Looking at this annotations, one can figure out everything about the CDS view. This annotation has absolutely NO impact on the behavior or output of the CDS view rather it just show below features;

    • What kind of data the CDS view expose.
    • What is the category of the CDS view.

@VDM annotation is further broken down into the type of views.  There are 4 type of CDS views can be developed;

-BASIC

Basic CDS views are developed to expose the Master Data like Customer Master, Material MAster, Business Partner etc. They consume the physical SAP tables to read data.  They are also called INTERFACE views and for naming standards SAP use ‘I’ in between of the view name : *_I_*

-COMPOSITE: 

These views are configures as an Association of Master data sets OR Master data and Transactional data. They can consume Basic Views or other Composite views to read data.  For naming standards, SAP use ‘CO’ in between of the view name: *_CO_*

-CONSUMPTION

These views are created as the last layer of CDS analytical Model.  These are the final views ready for consumption by the UI tools – Bex, Lumira, Webi, Analysis for Office etc. to be accessed by business users in the from of a report.  These views can consume all other Basic or Composite Views to read data and create a final data set to be fed into the UI tools for reports based on business requirements. For naming standards, SAP start the view name with ‘C’:  C_*

-PRIVATE

These views are private to SAP and must not be Used or Created by anyone other than SAP.  SAP can change their configuration without any notice to the customers.  For naming standards, SAP start the view name with ‘P’:  P_*

 

NOTE: When you look at the SAP standard views, now with above naming standards how easy it is to identify the purpose and behavior of each of the view.  You can easily know in which bucket the view fall into and how you can use it in your data model.

We can not use VDM annotations with Non S4HANA systems.  This needs HANA DB as a pre-requisite.

With @VDM annotation, if you apply all the standard procedures in the CDS view creation, It will be fairly easy for other developers who will see you code to understand the nature and purpose of the CDS view you have created.  This is one of the very important annotation for Quality Control and must be forced in an organization to achieve the Best Development Practices/Standards.

 

  • Let’s create a VDM based CDS view to showcase how this looks;
  1. Create a new view with ASSOCIATION template.
  2. Copy the code from our previous Association view to save time.

 

3. Add the VDM and Analytics annotations;

@VDM:{viewType: #BASIC} :

This annotation defines the type of the CDS view.  As mentioned above the type BASIC view are mostly used for Master Data and denotes that it is a BASIC Interface CDS view.

@Analytics:{dataExtraction:{enabled: true}, dataCategory: #DIMENSION}

This annotation defines if this CDS view is consumable by the Analytical applications.  For attention of BW folks, we can create a custom datasource out of a CDS view by using this annotation.  I will explain this in detail later.  This annotations tells that we can extract data out of ECC system to BW for example and the Data Category ‘DIMENSION’ defines that it is a Dimension data which could be a Master data set and later this can be combined with the Fact Table or CDS view type #CUBE.

Activate and execute this CDS view. There will be no difference you can see in the output with or without VDM or Analytics annotations. While we will configure BW Data Source from a CDS view then it will be very helpful.

 

In summary, before starting to develop any CDS view, we must understand the whole life cycle of the data this view is going to deliver.  It is a must to understand who is the consumer of this data coming out of this CDS view and then  use the required annotations accordingly.  Follow best SAP development practices and make the code look clean, easy to understand and best in performance.

 

Part# 11. End to End Data Modeling and Reporting with CDS views: Hands on with a complete business scenario for a simple analytical requirement.

 

Follow for upcoming blog posts: Sanjeev Kumar

Keep learning..

SK

 

 

 

 

 

 

 

Be the first to leave a comment
You must be Logged on to comment or reply to a post.