Friday, March 20, 2020

ABAP CDS Basics


                              ABAP CDS Basics


Code Pushdown is main motto of development of HANA Databases. We use this technology stack to develop our reports and business logic.

What is ABAP CDS?
 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]. 


What are ABAP CDS Entities?
ABAP CDS Entities are 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 Function
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.
A CDS View associated with the CDS Data Base View and the CDS entity are part of same namespace, so different names must be assigned to the database 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

What is ABAP CDS Table Functions:
These are table functions that are implemented natively on the database and can be called in CDS view. They support code push down capabilities in ABAP CDS.
A CDS Table Function is defined using statement DEFINE TABLE FUNCTION . In contrast to the CDS views , the CDS table functions can be implemented by using native SQL . The implementation is done within AMDP method of the AMDP class and is managed as an AMDP function by the AMDP framework in the DB.


HANA CDS Views In Simple Words- SAP ABAP ON HANA.


SAP HANA supports SQL as a means to define, read, and manipulate data. On top of SQL, many technologies introduce higher-level models to add semantics and ease consumption, such as OData EDM models, the semantic layer in the BI platform, JPA and enterprise objects in Java, and the business objects frameworks in ABAP. These higher-level models share many commonalities, but are usually specific to their technology. This prevents their re-use across stacks and increases effort for application developers. To address this, SAP introduces a set of domain-specific languages and services, called CDS, for defining and consuming semantically rich data models.


The Core data Services (CDS) views are collection of below three domain specific languages and services for consuming semantically rich data models.


  • Data Definition Language (DDL): The DDL part of CDS can be considered an enhancement of SQL that allows you to define semantically rich database tables and views, often referred to as CDS entities, and user-defined types in the database. This allows you to simplify and harmonize the way you define and consume your data models. The enhancements include annotations to enrich the data models with additional (domain-specific) metadata and associations on a conceptual level, replacing joins with simple path expressions in queries.
  • Query Language (QL): Views defined using the CDS DDL can be consumed in ABAP programs using the Open SQL query language, as well as in other CDS views. Open SQL has been extended to provide support for CDS entities. In addition, it is possible to query the CDS features supported by the underlying database before executing the Open SQL statement to enable alternative implementations.
  • Data Control Language (DCL): The DCL is used to define authorizations for CDS entities in a declarative way. The ABAP CDS authorization concept is a new concept and can be used independently or in combination with the classic concept. Whereas the classic authorization concept is based on authorization objects and the authorizations are checked either implicitly (when transactions are called) or explicitly (using the statement AUTHORITY CHECK), the CDS authorization concept is based on implicit checks automatically performed by the ABAP runtime when the CDS entity is accessed using Open SQL.


CDS are not only an integral part of SAP HANA, but can also be leveraged in the ABAP stack and are optimally integrated into the ABAP Dictionary and language. The corresponding new ABAP Repository object types DDL Source and DCL Source, for defining enhanced view entities in ABAP, allow you to push more data-intensive calculations to the database than is possible using classical ABAP Dictionary views.


You can use ABAP CDS views to read data and calculate additional information while reading data. ABAP CDS views do not support data modifications as of now.


Differences Between ABAP Dictionary Views & CDS Views:

ABAP CDS share with ABAP Dictionary views that are supported on all database systems and supported by the ABAP stack. However, ABAP CDS views provide the following additional capabilities:
  1. Enhanced support for combining queries, such as UNION and OUTER joins.
  2. Support for calculations that use expressions in the column list and for selection, as well as aggregation and grouping in the data model.
  3. Ability to be nested, which allows for more design for reuse.


Differences between SAP ABAP CDS Views and SAP HANA CDS Views