Abap CDS Views Imp Doc End To End
Abap CDS Views Imp Doc End To End
Abap CDS Views Imp Doc End To End
https://blogs.sap.com/2022/02/24/sap-cds-for-new-and-experienced-professionals/
https://blogs.sap.com/2022/02/24/consuming-cds-for-new-and-experienced-professionals-2/
https://blogs.sap.com/2022/02/25/cds-annotations-new-and-experienced-professionals-3/
https://blogs.sap.com/2022/02/25/cds-in-real-life-requirements-new-and-experienced-
professionals-4/
https://blogs.sap.com/2022/02/26/cds-architecture-new-and-experienced-professionals-5/
Disclaimer: If the screenshots look different that’s simply because I use dark theme in Eclipse.
Pre-Requisites:
Let’s Start:
We will take a more direct approach first instead of analysis lets follow the steps as below.
Step 1a:
When the new ABAP Package window appears – (* Are fields that are mandatory)
You will see Project: * as the system connection you are using don’t change that.
Click on next and You will get a window for selection of transport requests.
On the eclipse Project Explorer right click on the newly created package activate also add as a
favourite package.
Step 1b:Create another package following previous steps of Step 1a: with following parameters.
Step 2:
As Packages are now in place lets create a simple data dictionary / Table –
To do this Right Click on the package – ZTRAVEL_BOOKING_DDIC->New->Other ABAP Repository
Object
Search by typing the word table and select Database Table from the options.
Click on Next select the transport we created earlier and click on finish.
Step 2a:
To do this in Eclipse use the following syntax. – Do not worry about statements starting with “@” they are
called annotations I will explain them in an upcoming blog.
@EndUserText.label : ‘Employee Travel Details’
@AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table ztravel {
key client : abap.clnt;
key Employee_NO : char10 not null;
From_City : S_FROM_CIT;
TO_City : S_TO_CITY;
Note : In ECC 6.0 you normally create the same table from SE11 now it can be created from Eclipse.
Step 2b:
This table will be visible in SE11 or SE12 and can be viewed using Sap Gui (Logon Pad).
You can also notice the technical settings and delivery maintenance are pre-filled.
Note: This is an additional feature in Eclipse base development you the backend tables are created
with default settings.
Step 2c:
Create a table maintenance generator for the table from SAP GUI.
To do this first change the Delivery And Maintenance settings – > Display Maintenance Allowed
Step 2d:
Step 3:
Review: So far what we have done is created two packages using Eclipse.
Package 1- ZTRAVEL_BOOKING
Package 2- ZTRAVEL_BOOKING_DDIC
A data dictionary table with 4 fields and manually entered 10 records in to the table.
We will create a simple CDS view for the Database Table we just created called ZTRAVEL.
To Do this we need to jump to Eclipse again.
Right click on the package in your favourites- Select New->Other ABAP Repository Objects
Name : * – ZCDS_TRAVEL
and for the data source in line 6 please enter the following define view ZCDS_TRAVEL as select
from ZTRAVEL.
Now click Ctrl+Space from your windows keyboard to activate the quick search and select insert all
elements on to CDS.
You should now have all the fields from ZTRAVEL pulled into this view-
Lets check if this works. Right click on the CDS on the left hand side of project explorer ->Open With-
>Data Preview.
This should display the raw data in table ZTRAVEL.
Analysis:
Step1 – Open up the CDS view you will see two components SQL View called – ZVSQL_TRAVEL and a
data definition – ZCDS_TRAVEL
Step2 – If you display the SQL view you will have SAP Gui display within Eclipse. (ADT)
You will notice the difference from a classic projection view and a CDS view – A CDS view will have a
data definition and SQL View name.
Execute
So far the data , look and feel is exactly the same as any classic view. But CDS works differently the key is
the data model.
Trace:
Step1: Set up a trace using SAP Gui Logon pad with Transaction ST12.
In the SQL summary you can see the below- Interestingly the Data Domain is not captured.
If you look at the performance trace you will realize ZVSQL_TRAVEL is application-level SQL view
but ZCDS_TRAVEL data domain is running at the DB level and this is the major difference between
classical view and CDS Views.
Conclusion:
What is a CDS view – By now you can probably realize CDS view is not just one item it is actually a
combination of two items a Data Domain Model running at the DB level and a SQL view created with the
same data domain model visible at the application level.
In the below diagram *Courtesy SAP references – ABAP CDS Views (sap.com). This is explained quite
nicely – CDS is a bridge between SQL view and the table stored in the Data Base.
Congratulations now you have a better understanding of CDS Views and also created your first CDS. Keep
learning.
FollowLikeRSS Feed
Consuming CDS for – New And Experienced
professionals- 2
034,043
Premise-
There are many SAP blogs out there that explains inner working of CDS views or core data services in
SAP’s S/4 boxes. But there are still struggle among experienced professionals who is switching from ECC
system to S/4.
This blog is dedicated towards experienced professionals working on ECC systems for many years and
yet to jump to S/4.In the next few min, we will look at a very basic concept of a CDS view and try to
evaluate inner working of the CDS using classic SAP tools.
Pre-Requisites –
Lets Start –
At this point we have a CDS view created in the previous blog called – ZCDS_TRAVEL.
Like other views and dictionary tables we can consume a CDS view in ABAP executables-
We saw the below diagram in the previous blog also published in SAP help materials – *Courtesy SAP
references – ABAP CDS Views (sap.com)
CDS and SQL view both are part of ABAP Dictionary and you can access them both from SAP ABAP
Executables.
Executable – Consuming CDS view in a class and program.
Step2: Create new ABAP Class -> Right click new package ZTRAVEL_BOOKING_PROG->New-
>Search ABAP Class and click next.
Step3: Create two methods in the class one to select the data from ZCDS_TRAVEL another to publish the
read data.
Observations from the above code – A CDS view and classic view SQL operations are same syntax wise
for reading data.
Also while declaring variables using CDS view it works exactly the same way as transparent database
tables.
Step3: Lets create a program to review the data stored in CDS view. Create a new program called
ZCDS_REPORT_DATA executables in Eclipse.
ST12 Trace: Lets trace the program in ST12 and review the results. We already have the same result as
before the ZCDS_TRAVEL is not shown but the SQL view of the same is displayed in the trace from
ST12.
Conclusion:
CDS view can be consumed the same way the database view or table is because at the end of the day this is
part of SAP DATA dictionary.
Congratulations now you would be able to consume a CDS view in your programming.
Onto next learning unit – CDS Annotations – New And Experienced professionals- 3 | SAP Blogs
CDS Annotations for – New And Experienced
professionals- 3
059,580
Premise-
There are many SAP blogs out there that explains inner working of CDS views or core data services in
SAP’s S/4 boxes. But there are still struggle among experienced professionals who is switching from ECC
system to S/4.
This blog is dedicated towards experienced professionals working on ECC systems for many years and
yet to jump to S/4.In the next few min, we will look at a very basic concept of a CDS view and try to
evaluate inner working of the CDS using classic SAP tools.
Pre-Requisites –
Lets Start –
At this point you have understood CDS views a little better. Just to recap CDS views are not a single object
but an Entity consist of a SQL view and a Data Definition.
While creating our first CDS view we didn’t change the annotations written on top of CDS views.
The annotations are always start with “@” and there are few several pre-defined annotations.
Annotations are properties of a CDS entity. A way to enrich the CDS entity. These annotations are
evaluated at the run time to decide the behaviour of a CDS entity.
Lets try to decode some Header Annotations –
@AbapCatalog.sqlViewName: ‘ZVSQL_TRAVEL’ – Defines the SQL View name for the CDS entity.
@AbapCatalog.preserveKey: true –
Specifies the definition of the key fields in the CDS database view of the CDS view. (Whether to use
keys defined in the original data base table or the one defined in CDS views).
@AccessControl.authorizationCheck: #CHECK –
Authorization check for CDS. Defines the implicit access control when Open SQL is used to access
the CDS view.
Where can I see all SAP annotations for my current S/4 level?
o Answer: SAP Annotations are available in help document I have added as a reference to
this blog but also you can search annotation using SE16 from table –
ABDOC_CDS_ANNOS. Remember in this table you will see different kind of
annotations, not only related to ABAP CDS but others please refer to the references for
more just to give a little bit of more understanding see the categories as below.
o
Analytics Annotations
AnalyticsDetails Annotations
Consumption Annotations
DefaultAggregation Annotations
EnterpriseSearch Annotations
Hierarchy Annotations
ObjectModel Annotations
OData Annotations
Search Annotations
Semantics Annotations
UI Annotations
VDM Annotations
Important Tip – Take a look at table – CDSVIEWANNOPOS all the annotations related to a
CDS view can be found here. Also check CDS* in SE16 for other CDS views in your S/4 system.
Exercise- Lets add a simple ABAP Annotation (Header) to our existing CDS Header. start this by typing
“@” or CTRL+Space key from your keyboard.
Lets us add @AbapCatalog.buffering then press “.” to look at further options or hit CTRL+SPACE from
eclipse.
When you add the buffering type active and try to activate you might get an error. requesting to specify a
buffering type.
Defines the handling of obsolete data on a SAP HANA database when Open SQL is used to access the
CDS view – If we set this to True then open SQL will read all data and can lead to performance problems
if the database is really old and huge.
Where as if you set this to false then Open SQL will read only current data.
Conclusion:
Annotations are properties of CDS entity that allows us to pre-define behaviour of the CDS entity at
runtime. Congratulations now you know Annotations. Keep learning.
See you in the next blog – CDS in Real life requirements – New And Experienced professionals- 4 | SAP
Blogs
Reference Documents-
Premise-
There are many SAP blogs out there that explains inner working of CDS views or core data services in
SAP’s S/4 boxes. But there are still struggle among experienced professionals who is switching from ECC
system to S/4.
This blog is dedicated towards experienced professionals working on ECC systems for many years and
yet to jump to S/4.In the next few min, we will look at a very basic concept of a CDS view and try to
evaluate inner working of the CDS using classic SAP tools.
Pre-Requisites –
Recap-
Now at this point you were able to create a ZTABLE in sap which holds employee data and also created a
CDS view on top of the Table. We have gone through some basic examples to consume newly create CDS
view in ABAP executables.
Those basic building blocks will help you understand the current blog much better.
Lets Start –
The basic exercises are good but the real life examples are much different. So lets explore those together.
1. How do you find a Standard CDS view for a particular table in SAP?
2. What is a CDS extension?
3. How to extend a standard CDS view.
How do you find a Standard CDS view for a particular table in SAP?
o First and foremost topic to remember is use Standard CDS views as much as possible.
o SAP product teams have released different CDS views and can be used out of the box.
o To Find any standard view go to SE16- Look at table – DDLDEPENDENCY in the field
– OBJECTNAME enter the table name in wild chars to look for all the CDS views related
to the table.
o Lets do a small exercise – I would like to find CDS views related to table – ACDOCA.
o Now if you execute the filter you will see all the CDS views look towards the columns on
far right that explains Activation status of the CDS and also if this is a view – “VIEW” or
structured object “STOB”. If your requirement is to find out a view to extend remember
to always extend the items with “STOB”.
o Note – Please look at the SAP note – 2023690 – CDS views are inactive there are
situations during system upgrade, patching when CDS views are inactive and a consultant
might need to activate them. The note explain the procedure in detail.
o Activate DDL Sources – Go to SE38 – Enter program – RUTDDLSACT execute enter
the relevant information in the selection screen and execute. (Please use extra caution
and should not be done without a proper reason).
o Now lets follow the steps mentioned above and add a new field BLDAT to
F_MMIM_ACDOCA_ELE.
o
o
o
o Finally see the data structure –
Conclusion:
SAP Standard views can be extended to add more data definition and enrichment is possible, the process is
easy as long as you can identify the right view to extend.
Move on to the next blog. CDS Architecture – New And Experienced professionals- 5 | SAP Blogs
CDS Architecture – New And Experienced
professionals- 5
033,808
Premise-
There are many SAP blogs out there that explains inner working of CDS views or core data services in
SAP’s S/4 boxes. But there are still struggle among experienced professionals who is switching from ECC
system to S/4.
This blog is dedicated towards experienced professionals working on ECC systems for many years and
yet to jump to S/4.In the next few min, we will look at a very basic concept of a CDS view and try to
evaluate inner working of the CDS using classic SAP tools.
Pre-Requisites –
CDS in Real life requirements – New And Experienced professionals- 4 | SAP Blogs
Recap-
We started this journey with creating a simple CDS for a custom table in the first blog.
In the second blog we looked at simple way to consume CDS views in ABAP executables.
Lets Start –
What we haven’t looked at till this point is how CDS architecture is different than R/3 views.
This is extremely important to understand. Based on our experience in other four blogs let us list down
what we already know.
In R/3 Architecture the main component that decides which SQL statement to use is the Optimizer.
Now this process is slower and when the move to S/4 was decided one of the major changes proposed is
for programmers to use database operation with much ease and this is exactly what CDS does.
CDS Architecture:
CDS entities are a layer in between the DB and the application, this is an extremely powerful tool for
developers to be able to model data as per business need.
Code Pushdown is the main principal – This allows you to get rid of the optimizer and run some DB
modelling at the DB level instead of the application level.
Now combine this principal with HANA in memory DB. Then you have an extremely powerful concept
that merges Application/ DB layer into one mesh of systems.
Conclusion:
CDS Architecture is in the middle of application running on S/4 and the actual DB.
Now you know the architecture and hopefully a better understanding of CDS. Keep learning.
Next Blog – CDS Exposing to Odata – New And Experienced professionals- 6 | SAP Blogs
Premise-
There are many SAP blogs out there that explains inner working of CDS views or core data services in
SAP’s S/4 boxes. But there are still struggle among experienced professionals who is switching from ECC
system to S/4.
This blog is dedicated towards experienced professionals working on ECC systems for many years and
yet to jump to S/4.In the next few min, we will look at a very basic concept of a CDS view and try to
evaluate inner working of the CDS using classic SAP tools.
Pre-Requisites –
CDS in Real life requirements – New And Experienced professionals- 4 | SAP Blogs
Recap-
We started this journey with creating a simple CDS for a custom table in the first blog.
In the second blog we looked at simple way to consume CDS views in ABAP executables.
Target-
Current blog will be a overlap between CDS and ODATA topics. We have already looked at option to
consume CDS in any ABAP executables, this blog will explain how to expose CDS as a service using
ODATA.
Lets Start –
In First blog we created a data dictionary table named ZTRAVEL and a CDS view ZCDS_TRAVEL.
In this blog we will try to create a ODATA service to expose the CDS view.
Step1: Create a new sub package ZTRAVEL_BOOKING_ODATA in main ZTRAVEL_BOOKING
package. Go to transaction SEGW- (SAP Gateway Service Builder). Click on the new ICON.
Step2: Create a new ODATA project named – ZODATA_ZCDS_TRAVEL ( ODATA Project for CDS
Service ZCDS_TRAVEL). Enter the package ZTRAVEL_BOOKING_ODATA click on OK.
Step4: We will import the SQL view in this case ZVSQL_TRAVEL with the entity as CdsTravel.
Step5: You can choose the fields that you would like to expose as part of this ODATA – In this case
choose everything except client / Mandt.
Step6: Right Click on Service implementation CdsTravelSet and click on MAP to Data Source.
Step7: Find the CDS view via SADL model as shown below and click ok.
Step 8: Click on Generate Run time object button from toolbar. This will generate the below items
automatically click on Ok. Do no worry about what they are I will explain in the up coming blog in details.
Save the service.
Step9: Go to transaction /IWFND/MAINT_SERVICE in a new window. Click on Add service – Search
technical service Z*CDS* you will find the service we just created in Step 8. Once you find it select the
service and click on Get service.
Conclusion:
In exact 11 steps we were able expose CDS service as a ODATA. Congratulations, Keep learning