0% found this document useful (0 votes)
32 views11 pages

CDS General

Document explains CDS concept in SAP.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views11 pages

CDS General

Document explains CDS concept in SAP.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Core Data Service (CDS) :

What & Why CDS: To take advantage of SAP HANA for application development,
and to push down the code to the DB layer and to perform all operations on DB
layer, ABAPer needs a tool so that they Define & Consume Objects in DB layer itself,
hence SAP introduces a new data-modeling infrastructure known as Core Data
Services. With CDS, data-models are Defined and Consumed on Databases rather
than on Application Server.

Originally CDS was available only in Design time and Run time of SAP HANA
only( DB Backend). Now the CDS concept also implemented in SAP NetWeaver
Application Server(), enabling developers to work on ABAP layer with ABAP
development tools while the code execution is pushed down to DB layer.

Definition: Code Data Services are a collection of domain specific languages &
services for defining and consuming semantically rich data-model.

CDS Views: While the data in SAP is still physically stored in transparent tables,
CDS views are an abstract layer on top of the DB tables for data modelling
purposes. CDS views understand the relationship between data base tables and
hide the complexity from the ABAP developer. Created using an enhanced version
of Open SQL, CDS Views reside in the application server (Data Dictionary) but
process the logic in database as the data stored in the DB Tables.

CDS Simplify and Harmonize the way you define and consume your data-models
regardless of consumption technology. Technically it is an enhancement of SQL
which provides you with Data Definition Language for defining semantically rich
table view and user-defined types in the DB.

ABAP CDS provides a framework for defining and consuming semantic data models on the
DB of the ABAP AS. The data models are based on data definition language [DDL] and data
control language [DCL].

ABAP CDS vs HANA CDS

CDS comes in two flavours: ABAP CDS and HANA CDS. They share the same specification,
but their implementations differ. ABAP CDS initial focus is on view building and integration
into ABAP dictionary where HANA CDS focus is on building models from scratch.
HANA CDS is located on the SAP HANA DB directly and are used to develop native SAP
HANA applications (SAPA HANA XS), bypassing the ABAP application layer. If you are using
a SAP ERP system you should focus on ABAP CDS technology which is located on the
application server and fully integrated in the ABAP dictionary and the ABAP transport
system as its purpose is to support the implementation of ABAP applications.

Semantic Rich Data-Model:

Semantics: as attributes that help describe an underlying entity.

Example,

1. Creating Data element is expressed as defining the semantics’ of the Field


with its label of varying length.
2. Creating Domain the technical attributes Data type & Length is semantics of
Field*.

Data-Model provides a standardized method for defining and formatting database


contents consistently across systems, Data modeling is the process of diagramming
data flows. When creating a New or alternate Database Structure, the designer
starts with a diagram of how the data will flow into and out of the database. This
flow diagram is used to define the characteristics of the data formats, structures,
and database handling functions to efficiently support the dataflow requirements.
After the Database has been built and deployed, the data model lives on to become
the documentation and justification for why the database exists and how data flows
were designed.

The data model that results from this process provides a framework of relationships
between data elements within a database as well as a guide for use of the data.
Data models are a foundational element of software development and analytics.
They provide a standardized method for defining and formatting database contents
consistently across systems, enabling different applications to share the same data.

ABAP Dictionary Views Vs ABAP CDS Views:

If you are familiar with ABAP Dictionary Views, then you can think of a CDS views as
a much more sophisticated version.

ABAP Dictionary views just link the DB tables, but the CDS views bring many more
features such as calculations, aggregations, more variations of table joins, and they
can also be stacked with each other. The comparison is illustrated in the diagram
below.
Why ABAP CDS Views? – Classic vs Code Pushdown approach

The classic SAP development approach has been to keep the unnecessary load
away from the database. Developers would select the required data from a
database and do further processing and manipulation on the application server. The
code would become complex (as its majority has been built for performance
reasons) through the use of indexes and added no value to core 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’.

And “as much as possible” means: all expensive calculations, aggregations and
string operations should be done on the database level with only the resulting
sets to be transferred to the application layer. SAP HANA database is
optimised to complete such tasks. This leads to performance gains and reduction of
the the complex application code. For comparison – huge amounts of data had to be
transferred for processing with the classic approach. In some cases this could cause
short dumps due to memory consumption limits.

SAP HANA is capable of aggregating on the fly. There is no need for pre-built
aggregates and indexes since the data is organized using column stores. Also, in an
S/4HANA system the data model has been simplified, by getting rid of tables
necessary for aggregations and indexes.

The classic vs code pushdown (data centric approach) comparison can be


represented by the following diagram:

Code Pushdown – Example

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 classic approach, all these calculations and conversions would have been
done on the application server in ABAP. With CDS Views it is possible to do so on the
database level.

Consumption of CDS Views

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:

What are ABAP CDS Entities?

ABAP CDS Entities are data-models based on the Data Definition Language [DDL] and
managed by the ABAP Dictionary.
The ABAP CDS Entities are:

 ABAP CDS Views


 ABAP CDS Table Functions

What is ABAP CDS View?

A CDS view is defined on the existing database tables/views/other CDS views in ABAP
dictionary using specific DDL statement Define View. It serves to define the structure of
the CDS database view and represents a project on several database tables/views in ABAP
dictionary.

The CDS Data Base (SQL) View & the Entity associated with a CDS View are part of same
namespace, so different names must be assigned to the Data Base View and to the CDS
entity.

When a CDS View is activated it creates following objects in ABAP dictionary:

 Actual CDS Entity


 CDS Database View

CDS View Building Architecture


Understanding CDS from Native HANA Developers point of view:

With SAP HANA, it is possible to develop applications directly on Database. Here we


are not using Application Server anymore. Here there is a need to create meta-
model repository directly on DB.

Why & When CDS:

SAP HANA supports SQL as a mean to Define, Read & Manipulate data. On top of
SQL many technologies introduce higher level models to add semantics and its
consumption.

OData- Open Data protocol.

EDM- Energy Data Management model.


BI- Semantics layered in Business Intelligence BI platform.

JPA- Java Persistence API.

These above high-level models share many commonalities but are usually specific
to their technology. This prevents their reuse across the stack and increases the
effort for application developers to address these.

SAP introduces set of domain-specific Languages & Services called Core Data
Services for Defining& Consuming semantically rich data-models.

CDS Simplify & Harmonize the way you define and consume your data-models
regardless of consumption technology. Technically it is an enhancement of SQL
which provides you with Data Definition Language for defining semantically rich
table, view and user-defined types in the DB.

https://help.sap.com/doc/
1fa4facf5a4d49b0b8d9f5f28c678f70/1511%20001/en-US/frameset.htm?
7c078765ec6d4e6b88b71bdaf8a2bd9f.html

CDS: CDS is an extension of the ABAP Dictionary that allows you to create
semantically rich data models in the database and to use these data models in your
programs.

And an important is central part of enabling code push-down in ABAP applications.

In other terms, CDS is an infrastructure for defining & Consuming (using)


semantically rich data models.

The CURRENT variants are the database-independent ABAP CDS and HANA CDS.

ABAP CDS:: ABAP CDS implement the general CDS concept for AS ABAP.

1. They use the platform independent CDS DDL to define CDS Views and CDS
Table Functions that implement a semantic data model in ABAP Dictionary.
ABAP CDS is independent of database system.

2. A platform-independent CDS DCL makes it possible to develop CDS roles for


the CDS access control. Furthermore, specific classic objects in ABAP
Dictionary can be edited in the ABAP Development Tools (ADT) using syntax
based on the ABAP CDS CDS DDL.

***The entities of the models defined in ABAP CDS provide enhanced access
functions compared with existing
database tables and views defined in ABAP Dictionary, making it possible to
optimize Open SQL-based
applications. This is particularly clear when an AS ABAP uses a SAP HANA database,
since its in-memory
characteristics can be implemented in an optimum manner. ***
The data models are defined in the form of CDS objects using the data definition
language (DDL) and data control language (DCL) provided by ABAP CDS in the ABAP
CDS syntax in CDS source code. The CDS objects defined with these languages are
integrated into ABAP Dictionary and managed here.

Core data services are a new infrastructure for defining and consuming semantically
rich data model in SAP HANA. Using a data definition language (DDL), a query
language (QL), and an expression language (EL), CDS is envisioned to encompass
write operations, transaction semantics, constraints, and more .

CDS DDL:

Data definition language (DDL) of the ABAP CDS. CDS DDL contains language
elements for CDS data definitions in DDL source code, language elements for CDS
annotation definitions in DDLA source code, and language elements for CDS
metadata extensions in DDLX source code.

Data Definition Language. Subset of SQL. DDL statements create and delete
the objects of a relational database. In Application Server ABAP, DDL
functions are integrated into ABAP Dictionary in ABAP Workbench. ABAP CDS
offers a separate CDS DCL that covers SQL and expands on it.

CDS DCL: A platform-independent CDS DCL makes it possible to develop CDS roles
for the CDS access control.

CDS annotation:

A CDS annotation (or annotation for short) adds metadata to a CDS object
that expands the syntax options of SQL. The annotation is specified in a fixed
annotation syntax in the CDS source code of the CDS object. CDS annotation
definitions can be used to create CDS annotations themselves as CDS
objects. A definition of this type determines the semantics of the annotation
and dictates how it is specified in CDS source code. SAP delivers a
predefined set of SAP annotations.

ABAP CDS - Annotation Syntax

Syntax

@[<]Anno[: value ]
|[: { subannos } ]
|[: [ arrelem ] ]
|[.subAnno[ ... ]]

Effect
A CDS annotation is specified in CDS source code by using fixed annotation
syntax. This syntax dictates the following:

Example

The following DDL source code for defining a CDS view contains ABAP
annotations and other annotations at the allowed positions (in other words,
for the entire view, for the elements of the SELECT list, and for an input
parameter).

@EndUserText.label: 'Demo View with Annotations'


@AbapCatalog.sqlViewName: 'DEMO_VIEW_ANNOT'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.type: #CLIENT_DEPENDENT

The following are the CDS Objects which can be defined.

 CDS data definitions

CDS data definitions are made using the CDS DDL of the ABAP CDS.
They define the following CDS entities. These units can be accessed as
a data type (in ABAP programs) and as a data source (in Open SQL
read statements).

CDS entity: CDS Object in ABAP CDS managed by ABAP Dictionary. A


CDS entity is defined in a CDS data definition using the CDS DDL of the
ABAP CDS in a piece of CDS source code. A CDS entity becomes
significant when it is activated. Within the CDS, an entity can access
other entities. In ABAP programs, a CDS entity can be used as a data
type and Open SQL read statements can be used to access the entity.
Currently, CDS views and CDS table functions are available as entities

1. CDS views

CDS entities, which from a technical perspective are based on


CDS database views of the ABAP Dictionary.
2. CDS table functions

CDS entities, which are implemented in AMDP functions.

The CDS DDL of the ABAP CDS also contains language elements that
enhance CDS entities.

 CDS access controls

CDS access controls are based on CDS roles that are defined in CDS
DCL. When CDS entities that are assigned a CDS role are accessed,
additional access conditions are evaluated by default.

You might also like