What is SAP CDS Views? Core Data Service (CDS) Views are virtual data models of SAP HANA SAP HANA SAP HANA (HochleistungsANalyseAnwendung or High-performance ANalytic Application) is an in-memory, column-oriented, relational database management system developed and marketed by SAP SE. Its primary function as the software running a database server is to store and retrieve data as requested by the applications. https://en.wikipedia.org › wiki › SAP_HANA SAP HANA – Wikipedia which allows direct access to underlying tables of the HANA database . SAP CDS Views came into being with SAP’s new programming model. SAP CDS Views aim to push logic from the application server to the client-side and database.
Contents
- 1 ABAP Dictionary Views versus ABAP CDS Views
- 2 ABAP CDS Views: Classic vs Code Pushdown Approach
- 3 What is Code Pushdown in SAP ABAP?
- 4 Understanding CDS View Consumption in SAP ABAP
- 5 Understanding SAP CDS Views
- 6 Understanding the Significance of Annotations in SAP ABAP
- 7 What distinguishes calculation views from CDS views in SAP?
- 8 System Requirements
- 9 Reasons for Utilizing CDS Views in India
- 10 Development Environment
- 11 Using CDS view in ABAP program: A guide for beginners
- 12 ABAP CDS versus HANA CDS: A Comparison
- 13 What are the drawbacks of CDS view?
- 14 Distinguishing CDS view from SE11 view
- 15 Reading a CDS view: How can it be done?
- 16 How can I present information in SAP using CDS views?
- 17 The SAP CDS Language: An Overview
ABAP Dictionary Views versus ABAP CDS Views
If you have knowledge of ABAP Dictionary views, CDS Views can be seen as an advanced and enhanced version.
ABAP CDS Views: Classic vs Code Pushdown Approach
Traditionally, SAP developers have followed a method where they minimize the workload on the database. They would retrieve only the necessary data from the database and perform additional processing and modifications on the application server. This approach often led to complex code due to performance optimizations such as indexes, which did not contribute significantly to essential business functions.
With the invention of SAP HANA database and consequent introduction of ABAP CDS Views this approach has changed. The new programming paradigm is called ‘code pushdown’ or “code to data”. The rule-of-thumb is to ‘do as much as possible in the database to get the best performance’.
The goal is to minimize costly calculations, aggregations, and string operations by performing them on the database level. By utilizing the optimized SAP HANA database for these tasks, there are performance improvements and a decrease in complex application code. In contrast, the traditional approach required transferring large amounts of data for processing, which could lead to memory consumption issues and potential short dumps in certain situations.
SAP HANA has the ability to perform real-time aggregation without the need for pre-built aggregates and indexes. This is possible because data is organized using column stores, eliminating the necessity of tables required for aggregations and indexes in an S/4HANA system.
The comparison between the classic VS code pushdown and the data-centric approach can be visually represented by the diagram below.
What is Code Pushdown in SAP ABAP?
So, what does ‘code pushdown’ really mean? I am using an example of a CDS View below to explain:
Apart from regular fields selection from database table SBOOK this CDS view:
- Uses a cases statement, based on the value of CLASS field it will return a corresponding value: ‘Economy’, ‘Business’, ‘First’.
- Does a currency conversion from source currency to USD using a built-in function
- Calculates the difference between order date and flight date using a built-in function
In the traditional method, ABAP would handle all the calculations and conversions on the application server. However, CDS Views allow for these tasks to be performed directly on the database level.
Understanding CDS View Consumption in SAP ABAP
CDS Views can be consumed in many ways as a data source. Whether it is well known ALV report using ALV with Integrated Data Access (IDA) or modern SAP Fiori application with the CDS view exposed using SAP Gateway in the oData format. You can also quickly build FIORI apps on top of CDS Views with SAP FIORI Elements templates. CDS Views also work very well with SAP’s analytical apps using analytics related annotations and analytical engine. Below is a simplified diagram of CDS Views consumption:
Understanding SAP CDS Views
Practical advice for utilizing Code-to-Data or Code Pushdown with SAP CDS Views includes identifying computationally intensive operations that can be offloaded to clients or databases. For example, complex calculations involving large datasets could benefit from being performed closer to where the data is stored rather than sending all information back and forth between servers.
Another practical example would be moving filtering operations directly into a database query using SQL expressions within an SAP CDS View definition instead of retrieving all records and filtering them on the application server afterwards. This way, only relevant data is fetched from storage, reducing network traffic and improving response times.
Understanding the Significance of Annotations in SAP ABAP
As mentioned earlier, CDS views are created using openSQL and can be enhanced with annotations. These annotations serve different purposes: semantic (for S4HANA Embedded Analytics), analytical (for tools like Bex, Lumira), and UI annotations (for FIORI applications). The UI annotations are particularly interesting because by adding relevant annotations to the CDS view and utilizing SAP FIORI Elements, we can generate a FIORI app without needing to write any JavaScript code. The entire user interface is generated based on the CDS View and its accompanying UI annotations.
However, there are a few limitations to consider. For instance, CDS Views in SAP ABAP only support specific floorplans and lack the flexibility of freestyle SAPUI5 apps. Nonetheless, they excel at generating reports efficiently with filter bars. This is illustrated below, where the left side showcases a CDS View with UI annotations while the right side displays the resulting FIORI app.
The search annotation allows for a search dialogue to be implemented. It is responsible for including the Sales Order ID field in the selection dialog (filter bar). Additionally, it determines the placement of the Sales Order ID field in the output table.
What distinguishes calculation views from CDS views in SAP?
Calculation Views are objects that belong to the SAP HANA database layer. They are used for complex calculations and aggregations directly in the database. These views help in performing advanced analytics and reporting tasks efficiently by leveraging the power of the underlying HANA database. Calculation Views can be created using SQL or graphical modeling tools provided by SAP HANA.
The main difference between Calculation Views and CDS Views is their location within the technology stack. While Calculation Views reside in the SAP HANA database layer, CDS Views exist in the application layer (ABAP layer). This distinction determines how they are utilized and accessed within different parts of an SAP system architecture.
Overall, both types of views serve specific purposes: Calculation View focuses on powerful calculations performed at a lower level (database), while CDS View provides a higher-level abstraction for defining reusable data models within ABAP programs at an application level
System Requirements
CDS Views in SAP ABAP are designed to run on the ABAP SAP NetWeaver stack. They are compatible with various databases, but it is advisable to use them primarily with the SAP HANA Database for optimal performance. While technically any SAP ERP system running on SAP NetWeaver 7.4 SP05 can utilize CDS Views, using them with other databases may result in potential performance issues due to their optimization and testing being focused on the SAP HANA Database.
The functionalities available in CDS Views vary depending on the version of SAP NetWeaver you are using. While they were introduced in SAP NetWeaver ABAP 7.4 SP05, their capabilities were quite limited at that time. To ensure a smooth experience and avoid technical limitations, it is recommended to use SAP NetWeaver ABAP 7.5 or higher when developing CDS Views. Using lower versions may result in issues due to the lack of necessary features.
Reasons for Utilizing CDS Views in India
The benefit of having a unified data model is that it simplifies the process of accessing and analyzing data across different systems or applications. Instead of duplicating efforts by creating separate models for each application, developers can leverage CDS views to provide consistent and reliable information to all users.
Development Environment
Creating CDS views in SAP GUI is not feasible. The preferred tool for this purpose is the Eclipse IDE with the ABAP Development Tools (ADT) plugin. This platform caters to contemporary ABAP development and extends beyond just CDS views, allowing developers to work on various other objects like ABAP programs, classes, function modules, etc.
Using CDS view in ABAP program: A guide for beginners
Create a CDS view. In the context menu of your package choose New and then choose Other ABAP Repository Object.
– Enter the data source.
– Use an existing CDS association.
– Add fields from existing associations.
– Add a CASE statement.
– Add a WHERE clause.
– Check your code and view your changes.
– Test yourself.
ABAP CDS versus HANA CDS: A Comparison
There are two types of CDS Views: ABAP CDS Views and HANA CDS Views. Although they have the same specification, their implementations differ. ABAP CDS Views primarily focus on view building and integration into the ABAP dictionary, while HANA CDS Views concentrate on creating models from scratch. HANA CDS Views are located directly on the SAP HANA DB and are used for developing native SAP HANA applications (SAPA HANA XS), bypassing the ABAP application layer. If you use a SAP ERP system, it is recommended to prioritize ABAP CDS Views technology, which is situated on the application server and fully integrated into the ABAP dictionary and transport system. Its purpose is to support implementing ABAP applications.
Did you find Radek’s blog post helpful? Follow us on LinkedIn to stay up to date with all new content from the Absoft team.
What are the drawbacks of CDS view?
There are a few limitations when it comes to using Core Data Service (CDS) views in SAP ABAP. Firstly, you cannot debug CDS views, which means that it can be challenging to identify and fix any issues that may arise during development.
Secondly, CDS views are limited in terms of the output they can provide. They can only return one result set as output, which means that if you need multiple sets of data from different tables, you will have to find alternative solutions.
Lastly, CDS views have a limitation when it comes to joining fields with mismatched data types and lengths in two different tables. This means that if the fields you want to join do not have compatible data types or lengths, you will encounter difficulties while creating your CDS view.
1. Debugging CDS views is not possible.
2. Only one result set can be returned by a CDS view.
3. Joining fields with mismatched data types and lengths is restricted in CDS views.
These limitations should be taken into consideration when working with CDS views in SAP ABAP as they may impact the development process and functionality of your application.
Distinguishing CDS view from SE11 view
2. Enhanced Functionality: CDS views provide enhanced functionality compared to SE11 views. They support complex calculations, aggregations, joins across multiple tables/views, filtering conditions, sorting options, and more.
3. Reusability: CDS views promote reusability by allowing developers to create reusable building blocks that can be utilized in different applications or scenarios within the SAP system.
4. Performance Optimization: With its optimized query execution capabilities like pushdown mechanism for filtering and aggregation operations at the database level itself, CDS views help improve performance significantly.
5. Integration with Other Technologies: CDS views seamlessly integrate with other technologies like Core Data Services for ABAP (CDS for ABAP), OData services generation using annotations (for exposing data as RESTful APIs), analytical queries using Business Intelligence tools like SAP HANA Studio or Analysis Office.
Reading a CDS view: How can it be done?
To access the Data Preview for a specific CDS entity in SAP ABAP, you can follow these steps. First, right-click anywhere within the data definition of the entity. Then, choose “Open With” and select “Data Preview” from the options that appear. Another way to open the Data Preview is by placing your cursor anywhere in the database table definition and pressing Ctrl + F8. By doing this, you will be able to see the data returned by that particular CDS entity.
In simple terms, a CDS view in SAP ABAP is a virtual representation or projection of data stored in one or more database tables. It allows users to define complex queries and retrieve relevant information from multiple tables at once. The Data Preview feature provides an easy way to visualize and analyze this data without having to execute any actual transactions.
Here are some key points about CDS views:
1. Virtual representation: A CDS view does not physically store any data but acts as a logical layer on top of existing database tables.
2. Query flexibility: It enables users to define complex joins, filters, aggregations, calculations, etc., using SQL-like syntax.
3. Reusability: Once created, CDS views can be reused across different applications or reports without duplicating efforts.
4. Performance optimization: By leveraging advanced techniques like pushdown processing (executing operations directly on the database), CDS views offer improved performance compared to traditional approaches.
5. Integration with other tools: They seamlessly integrate with various SAP tools like Fiori apps and analytical reporting tools for enhanced functionality.
Overall, CDS views provide a powerful toolset for developers and analysts working with SAP ABAP systems by simplifying data retrieval and analysis tasks while ensuring optimal performance
How can I present information in SAP using CDS views?
To display a CDS view, click on the view from the list of CDS views on the overview page. Click the Preview button to view the data of your CDS view. 2. The Data Preview screen shows the raw line items data without any aggregation.
The SAP CDS Language: An Overview
P.S: The use of CDS is crucial for building applications with the SAP Cloud Application Programming Model (CAP) in India. It enables developers to define service definitions, data models, queries, and expressions using plain object notations in JavaScript. Additionally, CDS views offer a powerful way to create virtual data models that simplify complex structures by combining multiple database tables into one entity while providing efficient querying capabilities.