ABAP Keyword Documentation → ABAP - Dictionary → ABAP CDS in ABAP Dictionary → ABAP CDS - Annotations → ABAP CDS - Specifying Annotations
ABAP CDS Metadata Extensions
A CDS metadata extension (MDE) extends a CDS entity with CDS annotations that are not specified in the DDL source code of the data definition. Currently CDS metadata extensions can only be created for CDS views and abstract CDS entities.
A CDS metadata extension is a CDS object that is defined and transported in a separate piece of DDLX source code. These pieces of DDLX source code can only be edited in the ABAP Development Tools (ADT). DDLX source code can also be displayed in Repository Browser in ABAP Workbench. Once a CDS metadata extension has been activated for a CDS entity, the methods of the class CL_DD_DDL_ANNOTATION_SERVICE take the annotations of the associated metadata extensions into account by default when evaluating the annotations of this entity.
Alongside the CDS DDL statements for data definitions, there is a CDS DDL statement for defining metadata extensions in DDLX source code. A prerequisite for extending a CDS entity with metadata extensions is that the annotation @Metadata.allowExtensions (with the default value true) is specified in the DDL source code of the CDS entity.
A CDS entity can have more than one CDS metadata extension. The following rules determine which metadata extension to use to evaluate the annotations:
- Each metadata extension is assigned to a layer, such as branch, partner, or customer. The layer determines the priority of the evaluation.
- A metadata extension can be joined to a CDS variant. The CDS variant can be specified during the evaluation of the annotations of a CDS entity to select the metadata extension.
In an evaluation with the class CL_DD_DDL_ANNOTATION_SERVICE, the metadata extensions of the specified variant are searched for annotations first, and then the metadata extensions without a join to a variant. In each case, the priority is determined by the layers of the metadata extensions. Next, the direct and indirect annotations of the CDS entity itself are added that do not have an entry in a metadata extension.
For more information, see the following:
Other versions:
7.31 | 7.40 | 7.54
Notes
- The DDL source code and the activation of a CDS entity are completely independent of any metadata extensions for this entity. For this reason, a metadata extension can only add annotations that are not already evaluated during the activation of the CDS entity.
- Metadata extensions separate the way metadata is specified from the actual data definition, and thus support the separation of concerns (SoC) concept. Specifying the annotations that are not required to activate a CDS entity outside the DDL source code of the CDS entity has the following advantages:
- It greatly improves the readability of the DDL source code of a data definition if it does not have to list all the metadata.
- The metadata can be specified and transported independently of the data definition.
- Separating the activation of metadata from the data definition avoids the need for mass activation of dependent repository objects that can occur when activating a data definition.
- When using metadata extensions for framework-specific annotations, please note the relevant rules. Otherwise error messages can occur during framework-specific checks.
- Layers and CDS variants allow frameworks, partners, and customers to override the metadata of a CDS entity without making modifications.
- Metadata extensions can be connected to the Switch Framework, making them switchable.
- The program ABAP_DOCU_MDE_ANNOS shows all annotations that can be specified in metadata extensions.
Caution
CDS variants are not currently released for general use. It is not possible to define standalone CDS variants and the use of CDS variants in metadata extensions produces a syntax check warning.
Continue
ABAP CDS - DDL for Metadata Extensions