Data Model Projection
Data Model Projection
The data model projection consists of one CDS projection view for each data definition view of the data model.
Projection views provide means within the specific service to define service-specific projections including denormalization of the underlying data model. Fine-tuning, which does not belong to the general data model layer, is defined in projection views, for example, UI annotations, value helps, calculations, or defaulting.
For the CDS view projection, a subset of the CDS elements is projected in the projection view. These elements can be aliased, whereas the mapping is done automatically. That means that the elements can be renamed to match the business service context of the respective projection. You cannot add new persistent data elements in the projection views. Only the elements that are defined in the underlying data model can be reused in the projection. However, you can add virtual elements to projection views. These elements must be calculated by ABAP logic.
Creating the Projection View
To create the data definition for a CDS Projection view, we recommend using the context menu on the name of the data definition view. By doing so, the name of the data definition view is automatically set as Referenced Object and template define Projection View is pre-selected by default.
CDS Annotations for Service Metadata
From a design time point of view, the projection layer is the first service-specific layer. All service specific metadata must be defined in the CDS projection views via CDS annotations.
Element annotations that are not service-specific should be placed in the data model views from where they are propagated into the projection layer.
An example is annotation @semantics.amount.currencycode, which is used to establish the connection between an amount field and its currency code field.
The following service specifics are relevant on the projection layer:
It is common practice to outsource the UI-annotations of a projection view in a metadata extension. This increases readability and facilitates later adjustments of the UI through additional metadata extensions.
Service Definition
The Service Definition
A business service definition (or service definition) describes which CDS entities of a data model are to be exposed so that a specific business service can be enabled. It is an ABAP Repository object that describes the consumer-specific but protocol-agnostic perspective on a data model. This means that a service definition itself is independent of the version or type of the protocol that is used for the business service.
Creating the Service Definition
To create the service definition, we recommend using the context menu on the name of the CDS projection view. By doing so, the name of the projection view is automatically set as Exposed Entity.
Source Code of the Service Definition
The source code of the actual service definition is preceded by the optional CDS annotation @EndUserText.label that is available for all objects that can contain CDS annotations.
The service definition itself is initiated with the DEFINE SERVICE keyword followed by the name for the service definition.