Definition
Many technologies exist that introduce higher-level models on top of SQL to add semantics and ease consumption – for example, OData EDM models, the Semantic Layer in the BI platform, JPA and enterprise objects in Java, and the business objects frameworks in ABAP. Those 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 HANA introduced a set of domain-specific languages (DSL) and services called Core Data Services for defining and consuming semantically-rich data models.
- Core Data Services (CDS)
CDS introduce a common set of domain-specific languages (DSL) and services for defining and consuming semantically rich data models.
- Data Definition Language (DDL)
DL is used for defining semantically rich database tables/views (CDS entities) and user-defined types in the database.
- Data Control Language (DCL)
DCL is used to define authorizations for CDS entities. The main goal of CDS is to make the usage of SQL easier for application developers. DCL offers a possibility to define the authorizations needed for the CDS entities in a modeled, declarative way.
For more information, see the ABAP Authorization Concept for CDS Entities topic at http://help.sap.com.
The developer can either define sophisticated new views or simply wrap an existing table in a CDS view in order to enrich it semantically. For example, ABAP CDS offers a new authorization concept based on roles defined with DEFINE ROLE in a DCL (Data Control Language) source code. In order to let an existing table participate in the new authorization concept, the developer can simply create a CDS view for that table that is connected to a role.
CDS-Related Repository Objects
CDS View
As with conventional database views, the simplest form of a CDS view is a projection – that is, a selection of fields from a single table.
The language used is SQL Data Definition Language (DDL), but in an Open SQL form so that the view can be deployed on any database platform.
The name of the CDS entity is specified after the DEFINE VIEW statement. It is recommended, though not technically necessary, that the name of the DDL source and the name of the CDS view are identical.
CDS Role
CDS Access Control defines a CDS role. It relates the CDS role to one (or more) CDS views (keyword GRANT SELECT ON …) and defines access conditions for this CDS view (keyword WHERE …). Whenever an ABAP program accesses this CDS view, the database interface will automatically filter the selection result according to the access conditions.
The example shows an access control for flight bookings.
The access control automatically removes bookings for which the user does not have sufficient authorization.
Access Control - How it works
ABAP CDS enables access control based on a data control language (DCL). Access control in ABAP CDS further restricts the data returned from a CDS entity in ABAP CDS. CDS access control is based on the following:
- CDS roles defined using the DCL statement DEFINE ROLE. Currently, a CDS role is mapped to each user implicitly. This is why they are also known as mapping roles.
- Access conditions defined in a CDS role CDS entities. Access conditions can be the following:
- Literal conditions that compare elements of a CDS entity with literal values.
- PFCG conditions that associate elements of a CDS entity with authorizations in the SAP authorization concept.