Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
kumarsanjeev
Explorer
This is the second blog post on the CDS detailed explanations after the Introduction post.  Refer to the  Introduction and blog post indexes here: https://blogs.sap.com/2019/10/21/part1.-sap-cds-views-demystification/

 

Whenver a CDS view is created and activated, these 2 objects gets generated.  As I mentioned in the introduction, this enables Code-to-Data paradigm shift.

  1. DDIC SQL view - It is a Design Time Object and can be seen in tcode- SE11

  2. HANA View - It is a run time object and gets created in HANA DB


 

BASIC CDS VIEW:

For all the view I create, I will use FLIGHT demo tables and data to showcase the CDS technology.

  1. Create an ABAP project within Eclipse by logging in to S4 HANA system.

  2. Right click on your username under Local Objects and choose New->Other ABAP Repository Objects.  Core Data Services->Data Definition.






 

 



 

A simple view will be created.  All the statements starting with ‘@’ at the start of the view are called ‘ANNOTATIONS’ and they play a very important role in design and development of the CDS view.  They are the ‘Building Blocks’ behind the CDS views configuration.  They also define how the CDS view will behave in different scenarios.  I will talk about different kind and mostly used annotations.



Now let’s talk about the default annotations while creating the Basic view

  1. @AbapCatalog.sqlViewName: 'sql_view_name'.


Within first annotation, provide the SQL view name.  This is the DDIC SQL view which gets generated once the CDS view is activated and can be seen in tcode SE11.  This name must be of less than or equal to 16 characters as per DDIC SE11 view name limitations.  Also, the CDS view name and the SQL view name can NOT be same.  So choose a logical name, probably something similar to the CDS view name to keep it consistent.

 

  1. @AbapCatalog.compiler.compareFilter: true:


This annotation defines the behavior of the filtering the data i.e. this first compare the filter conditions and if they match then only the data is fetched.  If the CDS view has join conditions, they are executed only after the filter conditions are matched. In DDIC views data if first fetched and then filtered.

 

  1. @AbapCatalog.preserveKey: true


Another important annotation of CDS views.  As you know all the DB tables in SAP do have Keys defined and the CDS Views are always created on top of those DB tables.  Now any DB table can have multiple keys defined and you might not want those keys to be the key fields of your view.  So if you set this annotation as true, the only fields you define as Key Fields within your CDS view by adding word ‘Key’ in front of those fields will be the Key fields for the CDS view and the DDIC SQL view which gets generated.

If you set this as ‘False’ the DB table key fields will be defined as Key fields for the views as well, regardless of you adding word ‘Key’ in front of fewer fields.

 

  1. @AccessControl.authorizationCheck: #NOT_REQUIRED


This annotation is used to add ‘Security’ piece to the CDS view.  When CDS view is ready to be rolled out to a bigger audience within or outside the organization, it is very important to restrict the data based on the authority.  We will look into creation of authorization objects in the later part.  For now let’s keep it #NOT_REQUIRED

 

  1. @EndUserText.label: 'CDS View type #BASIC'


This annotation is used to apply business labels other than labels attached in the DB tables, to the fields within the CDS view.  This annotation will override the DB table business label and provides what you specify with this annotation.

 

Let’s add the fields to the CDS view by right click.  You can either choose to insert all fields or one by one;



Add the below fields to the CDS view;



 

I made the field ‘Client’ or ‘MANDT’ disabled due to the reason that this CDS view is created in the ABAP system and the client is handled by the system itself.  Now activate the CDS view.

 

As mentioned before, 2 more objects get created when the CDS view is activated?  A DDIC SQL view is created and a HANA view is created;

-Goto Tcode SE11 and check the DDIC SQL view;



 

-Check the HANA view in Eclipse or HANA Studio platform as below;



 

You can also check the ‘CREATE’ statement generated by the system.



 

To summarize, we created a basic CDS view and looked at the default annotations which are already configured when a CDS view is created. Also, we saw the different run time and design time objects which gets created with the view activation.

Part# 3. CDS view with Expressions and Session Variable: Find how to configure mathematical expressions and session variables to fetch system parameters.

Follow me for upcoming blog posts: kumarsanjeev

 

Keep learning..

SK.
8 Comments
junwu
Active Contributor
0 Kudos

  1. DDIC SQL view – It is a Design Time Object and can be seen in tcode- SE11

  2. HANA View – It is a run time object and gets created in HANA DB


are they not the same thing?

hana view is a runtime object?
kumarsanjeev
Explorer
0 Kudos
Hello Jun,

 

Yes, they can be treated same as they gets created when a CDS view is activated.  The actual Design Time object is the CDS entity.  Since the DDIC SQL view represents the CDS entity- the DDL source, so called it a Design Time object.  This is Code to Data paradigm concept.

Regards

Sanjeev.
Balu483
Participant
0 Kudos
hi sanjeev,

first of all i would like to thank you for sharing such a useful simple wording explenation .

i really like the way you explained each and every annotation with clear explanation.

i am expecting in upcomming blogs you are going to prepare in further salso will be in same manner.

thank you.
Balu483
Participant
0 Kudos
SQL views and CDS entities are part of one and the same namespace. Therefore, you must assign different names for an SQL view and the entity can you explain in detail about this problamatic statement ?



0 Kudos
@kumarsanjeev-

its a great blog for sure explaining the details very clearly.

i have one doubt regarding the client usage

"I made the field ‘Client’ or ‘MANDT’ disabled due to the reason that this CDS view is created in the ABAP system and the client is handled by the system itself."

Suppose your Dev System has 100, 200, 300 clients, and you are accessing this CDS view from 300 client; will your CDS view get records from all the clients or just 300 client.

i am sure your query will return data from all the clients since you haven't used any annotation wrt client handling or used $session.client

 

 

thanks

San

 
Sarang_Akhare
Explorer
0 Kudos
HI Sanjeev,

Helpful blog. Thank you for sharing.
kngupta141
Participant
0 Kudos
Hi Sanjeev,

 

Where can we find all annotations.

 

Thanks and regards,

Gupta

Hi Gupta,

Please check this link for list of CDS Annotations

CDS Annotations

 

Thank you,

Shivashankar

Labels in this area