What is CDS ?
CDS view is a service directly by HANA core
- CDS artifacts are present and execute on database(HANA or other) layer. This is called code push down where Application layer logic can be easily moved to Database layer for execution. This has many performance advantages if used carefully.
- Can be assigned to authorization object and visibility can be easily controlled
- CDS view can be easily consumed by oData service
- Can provide semantic information to each field which is particularly helpful when information is to be displayed on browser
- CDS can be buffered just like a transparent table
- Can be enabled for Search
- CDS can be used to define Data Hierarchy and relationships which is particularly helpful is navigation and drill downs
- Authorization objects: Authorization objects are generated based on the CDS view definition, which are used to control access to the CDS view.
- The GROUP BY clause is typically used in conjunction with aggregate functions, such as SUM, AVG, COUNT, and MAX, to calculate summary information about the grouped data.
What are different Types of CDS views ?
- CDS view
- Basic CDS view
- CDS View with Join
- CDS View with Association
- CDS View with Parameters
- Extended CDS view
- CDS View on View
Apart from that we also have Table Function and abstract entities
- Table Function
- Normal Table Function
- Table Function with Parameters
- Abstract Entity
- Normal Abstract Entity
- Abstract Entity with Parameters
2. Cardinality
- A [1..1] B means that for every row of A, there is a unique row in B and vice versa
- A[0..1] B or just A [1] B means that B may have a record for which there no source information in A.
- A [0..*] B means that B may have many records for which there no source information in A.
3. Table Function
Table function a CDS Data Definition Language(DDL) which uses syntax DEFINE TABLE FUNCTION

4. system variables
- $session.client is runtime SAP client which is equivalent to sy-mandt in AS ABAP
- $session.system_date is current system date and works same as sy-datum in AS ABAP
- $session.system_language works very similar to sy-langu in AS ABAP
- $session.user is essentially same as sy-uname in AS ABAP
5. @AbapCatalog.sqlViewName created corresponding DDIC structure
6. Max length of CDS – 30
7. How to create oData service from a CDS? – oData.Publish: True
8. It is not possible to debug CDS view. If a CDS is using Table function, then of course underlying AMDP can be debugged.
9. Path Expressions
Path expressions are used to navigate through associations in CDS views. In CDS views, associations are defined between entities using the association keyword. Path expressions use the association name and the cardinality symbols to navigate through the associations
10. Limitations of CDS
- Data Volume: ABAP CDS Views may not be the best choice for large data volumes.
- SQL-based limitations: ABAP CDS is based on SQL and as such, it has some limitations that are inherent to SQL.
11. Access control
One way to implement access control in ABAP CDS is to use the “AUTHORIZATION CHECK” statement in the view definition
Another way to implement access control in ABAP CDS is to use the ABAP Authorization Object concept.
12. Annotations
Annotations in SAP ABAP CDS (Core Data Services) are a special type of comment that can be added to CDS view definitions to provide additional metadata and information about the view
- Semantic information: Annotations can be used to provide additional information about the meaning of data fields in the view
- UI information: Annotations can be used to provide information that can be used to enhance the user interface of applications that use the view.
- Navigation information: Annotations can be used to specify relationships between CDS entities, which can be used to enable navigation between entities.
- @ObjectModel.relation” annotation can be used to specify a relationship between two entities in the view, such as a one-to-one or one-to-many relationship.
13. SAP List Viewer with Integrated Data Access (ALV with IDA) – ABAP on HANA provides ALV with IDA, which is an enhanced version of the standard ALV grid control.
14. ABAP Managed Database Procedures (AMDP) – ABAP on HANA provides AMDP, which is a programming model used to define and execute database procedures directly within the ABAP application server. AMDP allows developers to define database procedures using ABAP syntax, and it provides advanced data access and processing capabilities, including support for CDS views and Open SQL.
15. Best Practices
- Use Meaningful Names
- Define Relationships Carefully:
- annotations
- Optimize Query Performance: using Explain
- Test
16. DCL
Data Control Language (DCL) is used in ABAP CDS to define and enforce access control rules for database objects.
- GRANT: Grants access to a specific object or operation to a specific user or role.
- REVOKE: Revokes access to a specific object or operation from a specific user or role.
- DEFINE: Defines a new role or user group for access control purposes.
- SET PARAMETER: Sets system-wide parameters related to access control, such as the maximum number of connections allowed per user.
16. Extending CDS views
CDS View extension works by using the “EXTEND VIEW” keyword, which allows developers to create a new CDS view that references an existing view and adds or modifies its fields and properties.
17. Conversions
“@Consumption.valueMapping” annotation to specify the conversion factor for the unit or currency. For example, to convert a quantity field from “KG” to “G”, use the following annotation:
@Consumption.valueMapping: 'KG:1, G:0.001'
To convert a currency field, use the following annotation:
@Consumption.valueMapping: 'EUR:1, USD:1.2'
18. String in CDS
- CONCAT: This function is used to concatenate two or more strings.
Example:CONCAT('Hello', 'World')returns ‘HelloWorld’ - SUBSTRING: This function is used to extract a substring from a string.
Example:SUBSTRING('HelloWorld', 6, 5)returns ‘World’ - LENGTH: This function is used to determine the length of a string.
Example:LENGTH('HelloWorld')returns 10
19. The aggregate functions “SUM”, “AVG”, “MIN”, “MAX”, and “COUNT” are used in the SELECT clause to perform mathematical calculations
20. CDS Test Double Framework
The CDS Test Double Framework allows developers to create test doubles for CDS views that are used in the code being tested. This is useful when the CDS view is not yet available, or when the real data would be too difficult or time-consuming to set up for testing
@AbapCatalog.sqlViewName: 'ZVW_FLIGHTS'
@AccessControl.authorizationCheck: #CHECK
define view ZFlights as select from sflight {
carrid,
connid,
fldate,
price
}
@AbapCatalog.sqlViewName: 'ZVW_FLIGHTS_D'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view ZFlights_D as select from zfwk_test_dbl_view_provider->provide_view( 'ZVW_FLIGHTS' ) {
carrid,
connid,
fldate,
price
}
In this example, a new CDS view “ZFlights_D” is defined as the test double for the original view “ZFlights”. The data for the test double is provided by the “zfwk_test_dbl_view_provider” class using the “provide_view” method.
20. ABAP CDS Hierarchical Testing.
To perform ABAP CDS Hierarchical Testing, developers can use the ABAP Unit Testing framework, which provides a comprehensive set of tools and features to automate and simplify the testing process.
21. Types of views
In ABAP CDS (Core Data Services), there are three types of views: Basic, Composite (Association), and Consumption views.
- Basic Views: A Basic view is the simplest type of ABAP CDS view, which is based on a single database table.
- A Composite view is an ABAP CDS view that is based on multiple database tables, which are joined together through associations
- Consumption Views: A Consumption view is an ABAP CDS view that is based on existing Basic or Composite views
22. CDS in odata
Using ABAP Annotation: In this approach, developers can annotate their CDS views with OData-specific annotations that define the metadata required to expose the CDS view as an OData service. These annotations provide information such as the entity set name, the key fields, and the navigation properties
You can use the annotation modeler to add annotations such as @OData.publish, @OData.key, and @OData.navigationProperty.
Create a Data Service: Use the SAP Gateway Service Builder to create a new data service that will expose the CDS view as an OData service. In the Service Builder, you can define the entity set name, the key fields, and the navigation properties based on the annotations defined in the CDS view.
23. Firoi with CDS
- Define CDS Views: Define the required CDS views to fetch the data from the database. Use ABAP Development Tools in Eclipse to create CDS views.
- Define OData Service: Define the OData service for the CDS views using the annotations and annotations files.
- Define Fiori Elements: Define the Fiori Elements application using the annotations in the annotations file.
- Configure Launchpad: Configure the SAP Fiori Launchpad to add the new Fiori Elements application.
- Test the Application: Test the Fiori application by launching it from the Launchpad.
- Enhance the Application: Enhance the Fiori application by adding new functionality using SAPUI5 controls and libraries.
- Deploy the Application: Deploy the Fiori application to the SAP Fiori Launchpad to make it available to the users.
- Monitor the Application: Monitor the Fiori application using SAP Fiori Launchpad administration tools and resolve any issues that arise.
24. virtual element in CDS
a virtual element is a field that does not have a corresponding column in the database but is computed dynamically when the entity is read. Virtual elements allow you to add fields to your data model without adding them to the underlying data store.
@ObjectModel.virtualElement : true
25. Root view
The root view specifies the primary entity to be used in queries and forms the basis of the RESTful service that is automatically generated
26. Define view and define entity
DEFINE VIEW is used to define a view, which is a database object that provides a virtual representation of data from one or more underlying database tables. Views are used to present data to users or applications in a more meaningful way by joining or aggregating data from different tables. Views are read-only, and changes made to the view data do not affect the underlying tables.
On the other hand, DEFINE ENTITY is used to define an entity, which is a database object that represents a specific table or view. Entities are used to define the structure of a table or view, including its fields, keys, and relationships with other tables or views. Entities can be used to create or modify tables, views, or other database objects.
27. Composition in CDS
Composition with cardinality is a feature in ABAP CDS (Core Data Services) that allows you to define relationships between two or more entities. The use of composition with cardinality in ABAP CDS is to specify how entities are related and how they can be navigated.
In ABAP CDS (Core Data Services), an association to parent is a type of relationship that allows you to define a hierarchical structure between two entities. Specifically, it is a relationship between a child entity and a parent entity, where the child entity references the parent entity through a foreign key.
entity Employee {
key ID : Integer;
...
department : Association to Department;
}
entity Department {
key ID : Integer;
...
employees : Composition of many Employee on employees.department = $self;
}
28. The use of ET_EXPANDED_TECH_CLAUSES in ABAP CDS is to provide low-level control over the implementation details of the view.