CDS Views in SAP HANA and how to create one

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. SAP to AWS (Specifically S3) – Know as Easy Method

5 Ways to extract data from SAP S/4 HANA

Contents

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 Migrate Data from SAP Oracle to HANA

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.  SAP Extraction using ODP and SAP OData Services (2 Easy Methods)

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. Using SAP SLT Transformation Rule in SAP HANA

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. SAP ECC and Data Extraction from an LO Data Source

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. SAP HANA to Snowflake (2 Easy Ways)

Users can work with CDS Views both at ABAP level and at HANA Level with the same syntax and behaviour. Reliable SAP CDC and Data Provisioning in SAP

Advantages of CDS Views

Extract SAP Data by creating OData Service on ADSOs and SAP BW Queries


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. RISE with SAP (Everything You Need to Know)

  1. Creating CDS View for Extraction in HANA
    1. Create a Package
    2. Navigate to New ABAP repository Package and Create a Data Definition
    3. Select “Define View” template.
    4. Provide SQL View Name, Data Source Name and Add Annotations for Data Extraction Enablement and other properties of Data Extraction.
    5. Define the Query for data selection. and activate the CDS View.
  2. Creating an SAP OData Service on CDS View in HANA
    1. Go to Transaction SEGW, create a new project.
    2. Go to Data model, right click, and select ODP Extraction
    3. Provide the following details:
      1. The RFC Destination
      2. ODP Context as “ABAP Core Data Services
      3. ODP Name should be the name of the CDS View created.
    4. Click on “Add ODP” and provide all the details and complete the Steps.
    5. Click on “Generate” to generate the Service
  3. Registration of SAP OData Service created.
    1. Go to transaction /n/IWFND/MAINT_SERVICE. Click on “Add service
    2. In the next screen provide the system Alias and Service name to fetch the service details.
    3. 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.
    4. Navigate back to the main screen and click on filter, provide the service name.
    5. 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.
    6. In the new window click on the “Execute” button to test the service and notice the HTTP response.
    7. 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. The SAP Cloud Connector and Why It’s So Amazing

OUR SAP ETL Tool: BryteFlow SAP Data Lake Builder

Get a Free Trial of the SAP Data Lake Builder