Exploring ABAP Core Data Services

Objectives

After completing this lesson, you will be able to:

  • Describe the basic tasks of the ABAP Core Data Services
  • Name the most important ABAP CDS objects

ABAP CDS Functionality

ABAP Core Data Services (ABAP CDS)

Play the video to learn about ABAP Core Data Services (ABAP CDS).

Let us have a closer look at these tasks.

For a long time, ABAP developers defined views in the ABAP dictionary, in the same way they define database tables. These dictionary views were very limited in terms of SQL logic. They only supported inner joins, a field selection (projection) and simple filter conditions. Note, that the definition of dictionary views is not supported in cloud based ABAP environments.

One of the reasons why SAP introduced Core Data Services in ABAP was the demand for the execution of logic on the database. As you will learn later in this training, ABAP CDS views support a large variety of SQL expressions and functions to push down logic onto the database.

There are two types of CDS views.

CDS DDIC-based views (obsolete)

This obsolete type of CDS views uses a generated dictionary view as technical representation for the database object. CDS DDIC-based views are defined with the DEFINE VIEW statement.

CDS View Entities

This new generation of CDS views is defined with the DEFINE VIEW ENTITY statement. CDS view entities define the database object directly, without generating a dictionary object, first.

Note

In this training, we will only cover CDS view entities. For the older view types, refer to the ABAP keyword documentation.

ABAP CDS not only supports the technical definition of database objects. It also allows you to enrich the technical definitions with semantic information.

Let us have a look at an example.

CDS view entity Z00_C_Employee is defined with a define view entitystatement in a CDS data definition. This is the technical definition of the view, and it is used to create a view named Z00_C_EMPLOYEE on the database. In addition to the define view entity statement, the source code contains annotations. Annotations are code elements that enrich the technical view definition with semantic information. Annotations start with an at-sign (@).

Only a few annotations are evaluated by the ABAP system. The rest is simply passed on to the consumers of the CDS entity, that is, the frameworks that use the CDS entity to read data. The consumers decide by their own which annotations they evaluate and which they ignore.

The most important consumers of ABAP CDS entities are modern UI technologies like SAP Fiori and SAP S/4HANA embedded analytics.

The heart of the ABAP RESTful Application Programming Model is the Business Object.

The structure of the Business Object is modeled with one or more CDS view entities. A CDS behavior definition is used to add the transactional logic. The transactional logic is implemented in an ABAP behavior pool, an ABAP class in the ABAP source code library.

Business Objects are often consumed by Business Services, for example OData services. But you can also access them in ABAP code, using the Entity Manipulation Language (EML).

Note

The details of modeling, implementing and using Business Objects are not part of this training. They are discussed in a dedicated course on the ABAP RESTful Application Programming Model.

ABAP CDS Objects

Important CDS development objects are as follows:

CDS Data Definition

A CDS data definition contains the definition of one CDS entity. The most important CDS entities are CDS view entities and their predecessors, the now obsolete DDIC-based views.

But there are many other CDS entity types that you can define in a data definition:

  • CDS projection views are based on a CDS view and project a subset of its elements.
  • CDS Abstract Entities describe only type properties and for which no database objects are instantiated.
  • CDS Table Functions are implemented in database functions and return a tabular result set.
  • CDS Custom Entities are implemented manually, for example in ABAP code.
  • CDS Hierarchies define SQL hierarchies from an SQL source.
Note

In this training, we will focus on CDS View entities. For details on the other CDS entities, refer to the ABAP documentation.

CDS Access Control

CDS access controls contain the definition of a CDS role. When CDS SQL entities that are assigned a CDS role are accessed, additional access conditions are evaluated by default.

CDS Metadata Extension

CDS metadata extensions are used to store CDS annotations for a CDS entity outside its data definition.

CDS Behavior Definition

CDS Behavior Definitions define the transactional behavior of a business object.

 

In the Project Explorer of ABAP development tools, you find the CDS objects under the development package, in a dedicated node Core Data Services.

Log in to track your progress & complete quizzes