Skip to content

ABAP Keyword Documentation →  ABAP - Dictionary →  ABAP CDS in ABAP Dictionary →  ABAP CDS - Annotations →  ABAP CDS - Specifying Annotations →  ABAP CDS Metadata Extensions →  ABAP CDS - DDL for Metadata Extensions 


Other versions: 7.31 | 7.40 | 7.54

Syntax Forms





       ANNOTATE VIEW cds_entity WITH
         [VARIANT variant]
         { [element_list] }[;]


... VARIANT variant


Defines a CDS metadata extension (MDE for short) in dedicated DDLX source code.

Defines an MDE for any CDS entity except CDS table functions.
Defines an MDE specifically for a CDS view.

The CDS metadata extension adds metadata to a CDS entity as CDS annotations. The entity in question must exist, be specified using the name of its CDS entity cds_entity, and contains the annotation Metadata.allowExtensions with the default value true in its source code. A CDS entity can have more than one CDS metadata extension.

The annotation @Metadata.layer must be specified with one of the displayed enumeration symbols in front of the statement ANNOTATE to define the layer of the metadata extension. In the analysis of metadata extensions, the layer determines the priority of the metadata if there are multiple metadata extensions for the same CDS entity that is associated with the same CDS variant or not associated with any variants. The enumeration symbols are displayed with the lowest priority ones on the left and the highest priority on the right. #CORE therefore has the lowest, and #CUSTOMER the highest priority. If multiple CDS metadata extensions with none or the same CDS variant are assigned to the same layer, a syntax check warning is issued for annotations specified more than one, and the system uses the annotation of the first metadata extension found.

The annotations added to the extended entity are defined as follows. A metadata extension must contain at least one of these.

  • Annotations in front of the statement ANNOTATE
  • Only entity annotations @entity_annot can be specified in front of the statement ANNOTATE ENTITY. Valid SAP annotations must be in the scope of the entity annotations. They are added to the entity annotations of the extended entity.
  • Entity annotations and view annotations @view_annot can be specified in front of the statement ANNOTATE VIEW. Valid SAP annotations must be in the scope of the view annotations. They are added to the view annotations of the extended view.
  • parameter_list is used to specify annotations for the parameters of the extended entity.
  • element_list is used specify annotations for the elements of SELECT list of the extended entity.

In metadata extensions, only those annotations can be specified for which this is permitted in their annotation definition using the annotation @MetadataExtension.usageAllowed:true. In the CDS metadata extension, an annotation can be used in the same scope defined using @Scope as in a data definition. All other annotations produce syntax errors.

These annotations of a metadata extensions are respected in the evaluation of annotations with the methods of the class CL_DD_DDL_ANNOTATION_SERVICE except for GET_DIRECT_ANNOS_, in accordance with the layers defined by the annotation @Metadata.layer and in accordance with the used CDS variants. Here the annotations of a metadata extension always have a higher priority than the annotations specified in the source code of the CDS entity. These are only respected if they are not overridden by a corresponding annotation of a metadata extension. For the exact description of the evaluation, see section evaluation of metadata extensions.


  • Unlike the specification of annotations in the source code of the extended CDS entity, it is not possible to have any arbitrary annotations in metadata extensions; it is only possible to have SAP annotations. The syntax check for a metadata extension checks the validity of its specification with respect to the annotation definition:

  • the name of an annotation

  • the validity of the annotation values, the type, and (for enumerations) the enumeration symbol

  • whether any annotation arrays are specified correctly (they must only be specified using square brackets). The format @annot: value is not possible. @annot: [value] must be used instead. The array can contain only similar elements (in accordance with its definition).

  • The annotations (of a CDS entity) specified in metadata extensions does not have any effect on the activation or the behavior at runtime. They are only respected by the class CL_DD_DDL_ANNOTATION_SERVICE.

  • The program ABAP_DOCU_MDE_ANNOS shows all annotations that can be specified in metadata extensions.


The following metadata extension named DEMO_CDS_METADATA_EXTENSION adds annotations with original language "German" to the CDS view DEMO_CDS_PARAMETERS from the executable example for CDS views with parameters. The program DEMO_CDS_META_DATA_EXTENSIONS reads the annotations of the view with the methods of the classes CL_DD_DDL_ANNOTATION_SERVICE and CL_DD_DDL_ANALYZE. The method GET_ANNOS of the class CL_DD_DDL_ANNOTATION_SERVICE covers both the annotations specified in the metadata extension and the translations into the current text environment language. The method GET_ANNOTATIONS of the class CL_DD_DDL_ANALYZE only evaluates the specifications in the view DEMO_CDS_PARAMETERS.

@EndUserText.label: 'Demo für View mit Parametern'

annotate view demo_cds_parameters with
    @EndUserText.label: 'Untere Entfernungsgrenze'
    @EndUserText.label: 'Obere Entfernungsgrenze'
    @EndUserText.label: 'Einheit der Entfernung'
  @EndUserText.label: 'Fluggesellschaft'
  @EndUserText.label: 'Flugverbindung'
  @EndUserText.label: 'Abflug in Stadt'
  @EndUserText.label: 'Ankunft in Stadt'
  @EndUserText.label: 'Flugstrecke'
  @EndUserText.label: 'Einheit der Flugstrecke'


The following metadata extension DEMO_CDS_MDE_FOR_ABSTR_ENT adds entity annotations and element annotations to the abstract CDS entity DEMO_CDS_ABSTRACT_ENTITY_ELEM from the example for its element annotations.

@Metadata.layer: #CORE
@EndUserText.label : 'Label from MDE'
annotate entity demo_cds_abstract_entity_elem with
    @EndUserText.quickInfo: 'Quickinfo from MDE'


... VARIANT variant


Joins the metadata extension with a CDS variant. An existing CDS variant must be specified for variant. This entry is not case sensitive. If there are multiple metadata extensions for the same CDS entity contained in the layer defined with annotation @Metadata.layer, these extensions should be assigned to CDS variants, because otherwise a warning is raised by the syntax check for duplicate annotations.

In evaluations of annotations using the class CL_DD_DDL_ANNOTATION_SERVICE, the CDS variant can be specified to select the metadata extension. The class collects the annotations that it returned, in accordance with the layers and variants in line with the hierarchy described under the evaluation of metadata extensions.


  • CDS variants are created in the ADT and this creation process is documented there too.

  • From a technical perspective, the annotations specified in metadata extensions for a CDS entity are similar to the annotations specified in the DDL source code, separated by layers and variants in separate system tables and made accessible using an API. Annotations with translatable texts are also stored here in tables, which are connected to translation. The class CL_DD_DDL_ANNOTATION_SERVICE evaluates the system tables.


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.

Executable Example

CDS Metadata Extensions with CDS Variants


ABAP CDS - ANNOTATE, metadata_extension_annot

ABAP CDS - ANNOTATE, parameter_list

ABAP CDS - ANNOTATE, element_list