CDS Annotations
CDS Annotations
Table of Contents
Table of Contents 2
Overview 3
Framework-Specific Annotations 5
Aggregation Annotations 5
AccessControl Annotations 9
Analytics Annotations 11
Consumption Annotations 18
@Consumption.derivation 21
ObjectModel-Annotations 23
Semantics Annotations 26
AbapCatalog Annotations 33
2
Overview
Annotations are code snippets used to enable certain functions or to add component-specific
metadata to a CDS view. the statement which begins with @ called annotation, these are special
statements/ syntax which will enrich the CDS view.
Annotations are used to enrich the source code with meta information. They are relevant for the
generation of the views on the one hand and for the consumers of the CDS ABAP objects on the
other hand. Each framework has its own annotations for the CDS views, e.g. :
● @Analytics
● @Consumtion
● @EnterpriseSearch
● @ObjectModel
● @OData
● @UI
Annotations syntax
Values of an annotation
➔ Depending on their placement, annotations can be Header annotations (affect the entire view
and placed in the header of the file) or Body annotations (affect only the line of code in front of
3
which they are placed) Annotations provide domain-specific metadata to enhance the data
models.
The following list summarizes SAP annotations of the Data Definition Language (DDL)
of ABAP CDS that are relevant in the context of ABAP RESTful programming model
and released for ABAP Cloud Platform.
SAP CDS annotations are evaluated by SAP frameworks and can be either ABAP
annotations or framework-specific annotations.
■ AbapCatalog Annotations
■ AccessControl Annotations
■ ClientHandling Annotations
■ EndUserText Annotations
■ Environment Annotations
■ MappingRole Annotations
■ Metadata Annotations
■ Semantics Annotations
4
Framework-Specific Annotations
Framework-specific CDS annotations (as a rule) are exposed for OData and
evaluated during runtime.
■ Aggregation Annotations
■ AccessControl Annotations
■ Consumption Annotations
■ ObjectModel Annotations
■ OData Annotations
■ Search Annotations
■ Semantics Annotations
■ UI Annotations
Aggregation Annotations
With this annotation, you can specify the aggregation behaviour of elements in
generic usage like analytic manager or ODATA. Elements without default
aggregation or with Aggregation.default: #NONE will not be aggregated
and will be used in GROUP BY for aggregating access. Elements that can be
aggregated are known as measures.
5
6
7
AccessControl Annotations
Enable application developers to define how the authorization check for a CDS entity is
executed.
8
NOTE
9
Example
At runtime, if there is a role for the entity, then ABAP performs an authorization
check with the role. If there is no role, there is no check and no protection for the
entity.
Analytics Annotations
10
Usage
The Analytic Manager needs a star schema (multidimensional) and a query to consume
the data. Most annotations to define the star schema in different CDS views are
specified in ObjectModel annotations. Some Semantics annotations are also relevant.
The Analytics annotations also specify the facts (center of the star schema),
extraction capabilities for replicating data into further systems, and analytic query
properties. A semantic distinction can be made in the Analytics annotations between
annotations that are relevant for the InfoProvider (CUBE or DIMENSION) level and
annotations that are only relevant for analytic queries.
11
12
13
14
15
16
For more Analytics Annotation, please visit: Analytics Annotations.
Consumption Annotations
Usage
Via these annotations, the specific behavior is defined which is related to the
consumption of CDS content. This metadata makes no assumptions about the concrete
17
consumption technology/infrastructure, but it is applicable across multiple consumption
technologies (e.g. Analytics or OData).
18
19
Consumption.derivation
20
The binding specifies whether an input parameter or an element filter is used for
the binding.
21
ObjectModel-Annotations
22
23
The most used annotations:
24
Semantics Annotations
Used by the core engines for data processing and data consumption.
Usage
25
26
27
28
29
30
For more Semantics Annotations, please visit: Semantics Annotations.
31
AbapCatalog Annotations
32
33