Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member706122
Participant

  • 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.


 

 

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 1: Create a package first.

Right click on the Eclipse Connection link -> In the project Explorer

(This is the SAP system connection you just created).

Click on New->ABAP Package


 

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.

Name: * - Give a name of package – ZTRAVEL_BOOKING

Description: * - Give a description – Travel Booking Package

Package Type * - By default would be “Development” keep it as it is.

Click on Next- Enter software component as HOME






  • Click on next and You will get a window for selection of transport requests.

    Select Radio button- Create a new request –

    Request Description: * CDS for Experienced professionals

    Click on Finish.


    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.


Name: * - Give a name of package – ZTRAVEL_BOOKING_DDIC

Description: * - Give a description – Data Dictionary - Travel Booking Package

Superpackage: ZTRAVEL_BOOKING


 

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.


Enter as per below-


Name: * - ZTRAVEL

Description: * - Employee Travel Details


Click on Next select the transport we created earlier and click on finish.

 

Step 2a:

We will now create Four fields in this table -

Field name - Client  Data Type - MANDT

Field name - Employee_No  Data Type - Char10

Field name - From_City  Data Type - S_FROM_CIT

Field name - To_City Data Type - S_TO_CITY

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.

Once you complete the above Step activate the table.

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

Activate the table.

 

Step 2d:

From the Menu please select utilities->Table Maintenance Generator.

Enter Authorization Group - &NC&

Function Group - ZTRAVEL_TMG

Maintenance type - One Step

Overview Screen - 9001

Press F6 and Create the TMG.

 

Step 3:

Enter a few values into the TMG using SM30.





















































100001 NEW YORK SAN FRANCISCO
100002 SAN FRANCISCO NEW YORK
100003 ROME FRANKFURT
100004 ROME TOKYO
100005 TOKYO ROME
100006 ROME OSAKA
100007 NEW YORK FRANKFURT
100008 NEW YORK SAN FRANCISCO
100009 SAN FRANCISCO NEW YORK
100010 TOKYO FRANKFURT

 

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.


 

Lets Create a CDS View:

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

When the Pop up appears search by typing the word "Core"

Select Data Definition->Click on Next


 

Name : *  - ZCDS_TRAVEL

Description : * - CDS View for Travel Data

Click next select the transport and click finish.


Now against the annotations - @AbapCatalog.sqlViewName: please enter a sqlViewName as ZVSQL_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-


Now as final step - Activate your CDS.

 

Test the CDS:

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:

Now lets analyse the CDS view from Eclipse. - >

 

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.

Step3: Check in SE16N -


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.

 

Move on to next blog - Consuming CDS views

Consuming CDS for – New And Experienced professionals- 2 | SAP Blogs

 
6 Comments
Labels in this area