Before we further move to understand CDS in-depth, first we would like to understand the artifacts which support CDS view.
When CDS is created, Developer needs to enter three artifact names which together work as a CDS. All three artifacts are created in the custom namespace and their name must start with Z or Y.
The artifacts created during CDS creation are:
- DDLS(Data Definition Language Source) – We enter DDLS name along with package name and Description
- VIEW(A structure which can be seen in SE11) – is mentioned with annotation @AbapCatalog.sqlViewName. Just press Control and Click on View name and it leads to SE11 structure
- STOB(Structured Object) – is mentioned with ‘define view’ or ‘extend view’ syntax.
This is important to understand that when CDS is consumed from ABAP in a query, STOB object should be used to make SELECT. The query should not be made on DDLS or VIEW object.
CDS can be created with Eclipse in an ‘ABAP Project’. To create a CDS, follow steps:
- In Project Explorer, Right Click on Project > New > Other > Core Data Services > Data Definition
- Provide Package(enter $TMP for local objects), Name(should start with Y or Z) and Description
- Click Next to select Transport if Package is not $TMP. Either an existing transport to ve selected or new Transport to be created
- Click Next and Select one of the Template based on which type of CDS you need to create
- Click Finish and Editor opens with selected template in EDIT mode
- Write your CDS in Editor