CDS Views in SAP HANA Overview and Tutorial
This is an overview of SAP CDS Views, SAP CDS, and the role of CDS Views in SAP HANA. We will also learn how to expose CDS Views in SAP HANA as an SAP OData Service to replicate data to the Cloud. There are various protocols to access and extract data from SAP applications for analytics. This is one method using SAP CDS Views on SAP HANA via the ODP framework.
- What is SAP CDS?
- What is SAP CDS Views?
- Types of CDS Views: HANA CDS Views and ABAP CDS Views
- SAP CDS Views: Associations, Expressions and Annotations
- Advantages of CDS Views
- CDS Views exposed in SAP HANA as an OData Service: Architecture Overview
- Extracting data with CDS Views in SAP HANA via ODP
- How to create a CDS View in SAP HANA and an SAP OData Service to replicate data
- Our SAP ETL Tool: BryteFlow SAP Data Lake Builder
What is SAP CDS?
SAP CDS stands for SAP Core Data Services. SAP CDS is an infrastructure for data modelling that enables data models to be defined and consumed on the database server rather than the application server. This helps users leverage SAP HANA’s powerful in-memory database and fulfil the requirement for fast, real-time performance by performing maximum operations at database level (think resource-consuming calculations, aggregations and string operations), enabling users to retrieve data fast, cutting down on application execution time. Developers use SAP CDS to create the underlying data model that application services expose to UI clients as SAP CDS Views. Extract SAP data with business logic intact
What is SAP CDS Views?
Core Data Service (CDS) Views are virtual data models of SAP HANA 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. This is defined by SAP as ‘Code -to-Data’ or ‘Code Pushdown’. An SAP CDS View is what performs the ‘Code-to-Data’ or ‘Code Pushdown’. The SAP CDS View picks up the logic from the ABAP application and executes it on the database rather than the application server. How to create an SAP Extractor for SAP BW
Types of CDS Views: HANA CDS Views and ABAP CDS Views
SAP CDS Views are of 2 types: HANA CDS Views and ABAP CDS views. Earlier SAP CDS Views were only available in the SAP HANA environment but now CDS is also enabled in SAP NetWeaver AS ABAP allowing developers to work with ABAP programming tools in the ABAP layer while execution of the code is pushed down to the database (SAP CDS is fully integrated with SAP NetWeaver). SAP CDS supports conceptual modelling, built-in functions and extensions, and relationship definitions, which is much more than traditional data modelling tools offer. Getting data right for SAP Analytics
SAP CDS Views: Associations, Expressions and Annotations
SAP CDS streamlines and simplifies definition and consumption of SAP data models without needing to consider the technology by which they will be consumed. CDS as an infrastructure layer enables developers to define semantically rich data models (SAP CDS Views). They can define entity types like Orders, Partners or Products and the semantic relationships between them. CDS uses SQL based DDL (Data Definition Language) and is enhanced with some additional concepts:
Associations: These define the relationships between SAP CDS Views and annotations and direct the use of CDS artifacts on specific domains. On a conceptual level, joins are replaced with simple path expressions in queries.
Expressions: These are used in situations where specific CDS attributes are considered as values to be aggregated. In the data model they are used for calculations and queries.
Annotations: These are code snippets for enabling specific functions or for adding metadata that is component-specific to a CDS View. Depending on their placement, annotations can be Header annotations (affect the entire view and placed in the header of the file) or Body annotations (affect only the line of code in front of which they are placed) Annotations provide domain-specific metadata to enhance the data models.
Users can work with CDS Views both at ABAP level and at HANA Level with the same syntax and behaviour. How to simplify SAP Data Integration
Advantages of CDS Views
- CDS Views can be exposed as an OData Service for accessing and extracting SAP data. How to create an SAP OData Service in BW
- CDS Views are database independent and are comparable to Open SQL. They can be run on any database system that supports SAP. BryteFlow for SAP Data Replication
- CDS views support open SQL and they can be called in the same way as an SE11 view to the application layer.
- In CDS Views, calculated fields are possible (for example, totalling two fields at runtime).
- CDS Views support GROUP BY, WHERE, HAVING, UNION clauses.
- CDS Views provide support for full join, cross join, inner join, outer join, and right outer join.
- CDS Views support Aggregation and Numeric functions.
- CDS Views support automatic client handling.
CDS Views exposed in SAP HANA as an OData Service: Architecture Overview
Extracting data with CDS Views in SAP HANA via ODP
One of the ways SAP Data can be unlocked to the outside world is by building an SAP OData Service on CDS Views which acts as a data extractor. CDS Views can provide the full data directly, Initial and Deltas via the ODP (Operational Data Provisioning) Framework where ODP manages the Delta Queue. The Delta data extraction is managed through delta tokens which are based on timestamps. ETL SAP data with business logic intact
How to create a CDS View in SAP HANA and SAP OData Service to replicate data
In the steps below, we describe how to create a CDS View in SAP HANA, enable it for extraction then build an SAP OData Service for replicating the SAP data to the Cloud.
- Creating CDS View for Extraction in HANA
- Create a Package
- Navigate to New ABAP repository Package and Create a Data Definition
- Select “Define View” template.
- Provide SQL View Name, Data Source Name and Add Annotations for Data Extraction Enablement and other properties of Data Extraction.
- Define the Query for data selection. and activate the CDS View.
- Creating an SAP OData Service on CDS View in HANA
- Go to Transaction SEGW, create a new project.
- Go to Data model, right click, and select ODP Extraction
- Provide the following details:
- The RFC Destination
- ODP Context as “ABAP Core Data Services”
- ODP Name should be the name of the CDS View created.
- Click on “Add ODP” and provide all the details and complete the Steps.
- Click on “Generate” to generate the Service
- Registration of SAP OData Service created.
- Go to transaction /n/IWFND/MAINT_SERVICE. Click on “Add service”
- In the next screen provide the system Alias and Service name to fetch the service details.
- Select the service and click on “Add Selected Service” this will register the SAP OData service. A popup message will appear upon successful registration of service.
- Navigate back to the main screen and click on filter, provide the service name.
- Upon successful registration the SAP OData service will show up here. Click on the service and hit the “SAP Gateway Client” button to test the service.
- In the new window click on the “Execute” button to test the service and notice the HTTP response.
- A successful working service will show a status code as 200 as below.
Once the SAP OData service is ready and successfully tested, it is ready to be consumed by our SAP ETL tool, the BryteFlow SAP Data Lake Builder or any other suitable tool of your choice, for the data to be extracted from SAP and loaded into any cloud system.
OUR SAP ETL Tool: BryteFlow SAP Data Lake Builder
- Our SAP ETL tool can connect to SAP Data Extractors or SAP CDS Views to get the data from SAP applications like SAP ECC, S4HANA, SAP BW, SAP HANA. It automates SAP data extraction, using SAP OData Services to extract the data, both initial and incremental or deltas.
- The SAP ETL tool can also do log based Changed Data Capture from the database using transaction logs if the underlying SAP database is accessible.
- Deltas are merged automatically with initial data to keep the SAP Data Lake or SAP Data Warehouse continually updated for real-time SAP ETL.
- SAP data extraction, merging, masking, or type 2 history is all automated -no coding required. No third-party tools like Apache Hudi are needed.
- Data in your SAP Data Lake or SAP Data Warehouse is ready to use. Best practices and high performance for SAP integration on Snowflake, Redshift, S3, Azure Synapse, Azure SQL DB and SQL Server