ABAP CDS. A Brief Overview

A quick review of ABAP CDS as a tool for creating data models and their subsequent use in ABAP constructs.

A lot of interesting material has been written about the ABAP CDS toolset, so it probably doesn't make much sense to focus on it separately. However, to have something to refer back to if needed, I’ll leave a few paragraphs here on the subject.

See: About the ABAP CDS Development User Guide

What is CDS?

Core Data Services. A tool that allows you to create data views/perspectives using DDL (Data Definition Language). There are several types of such views, and all of them are quite well described in the vendor's documentation.

See: ABAP CDS Entities

It’s important to note that these data views/perspectives can be used in ABAP programs/classes/Function Modules, etc., and can also be utilized in the creation of OData services (which is especially valuable). Another interesting aspect is the configuration of access controls for these views, which I will describe later.

How to start working with this tool?

See: Installing ABAP Development Tools

See: Configuring the ABAP Back-end for ABAP Development Tools

Where to download Eclipse IDE?

See: SAP Development Tools → Hana Tools
See: Eclipse Packages | The Eclipse Foundation

Example of creating a CDS View

Suppose I need to create a CDS View that reads data from two tables.

Using Eclipse IDE, I try to create such a data model.

0:00
/2:01

After saving and activating the CDS View, in the back-end system, you can access the newly created objects via transaction SE11.

0:00
/0:53

How to reference a CDS View in ABAP?

The answer is quite simple. The following video fragment presents an example of referencing a CDS View in an ABAP program.

0:00
/0:56

Example of creating a CDS Access View

You can dislike Eclipse IDE as a tool for working with SAP system objects as much as you want, but here I think it’s fair to agree that it’s several times better than SAPGUI for Java and its ABAP code "editor." Dear SAP, if you are reading this, please have mercy on developers and consultants! 🙏 But I digress slightly from the main topic.

In Eclipse IDE, you should pay attention to the error/warning messages that sometimes appear. For instance, after you create and activate a new CDS View, the system may prompt you to note the absence of Access Control for it.

See: Access Controls
ABAP Core Data Services (CDS) has its own authorization concept – CDS access controls – using a Data Control Language (DCL). The authorization concept of ABAP CDS uses conditions defined within CDS and can draw upon classical (PFCG) authorizations to check user permissions.

The CDS authorization concept coexists with the classical authorization concept of the ABAP Application Server (AS ABAP). You can use both concepts together or separately. The classical authorization concept is based on authorization objects, where user authorization occurs either implicitly (e.g., when calling a transaction) or explicitly with the AUTHORITY-CHECK statement. The CDS authorization concept is based on implicit authorization checks during access attempts to CDS entities through ABAP SQL.

By working with Access Control, I can define the level of user access to the data collected/displayed in the created CDS View.

To demonstrate a simple scenario of working with this entity, I will configure two access options to the created CDS View, using the presence of a specific authorization object with a certain value in the user's role as the deciding factor for granting access. The next video fragment covers this.

0:00
/1:23

Continuing this topic, I want to emphasize that access to the data displayed in the created CDS View is granted through the check for the presence of authorization objects listed in the aspect pfcg_auth expression (e.g., S_CNTOR, CONTRYORG).

See: ABAP CDS – DEFINE ROLE, pfcg_condition

I had previously created an authorization object S_CNTOR with a filter CONTRYORG, which should ultimately be assigned to the user's role.

See the SAP note: How to create a custom authorization object?

Testing Access to the View

The next video fragment shows the sequence of steps where a role is created, and the previously created S_CNTOR authorization object is added to it.
Two values are assigned to this authorization object, matching those defined in the Access Control settings.

This is followed by running an ABAP program that executes a standard SELECT on the CDS View, and also directly viewing the data in the CDS View within Eclipse IDE.

0:00
/2:57
💡
Версия на русском: ABAP CDS. Коротко о главном