Skip to content

ABAP Keyword Documentation →  ABAP - Dictionary →  ABAP CDS in ABAP Dictionary →  ABAP CDS - Annotations →  ABAP CDS - Specifying Annotations 

ABAP CDS - Annotation Syntax

Other versions: 7.31 | 7.40 | 7.54


@[<]Anno[: value ]
       |[: { subannos } ]
       |[: [ arrelem ] ]
       |[.subAnno[ ... ]]


A CDS annotation is specified in CDS source code by using fixed annotation syntax. This syntax dictates the following:

  • The annotation is introduced using the character @ or the characters @<. @< is used when specifying the annotation after a list element in a comma-separated or semicolon-separated list.
  • A main annotation Anno consisting of letters, numbers, and underscores and starting with a letter. A main annotation that is not structured using subannotations can be specified precisely once in a scope.
  • One of the following optional alternatives specified after a colon (:):
  • The main annotation Anno concatenated with a subannotation subAnno using a period (.). The combination Anno.subAnno is a structured annotation name that can be extended using further subannotations.

An annotation name must be unique within a scope. Only those annotations should be specified for which a CDS annotation definition exists. Alongside the syntax rules above, the annotation definition also specifies the following:

  • The annotations of an annotation definition specify the scope of the annotation, whether it can be moved to metadata extensions, and whether a particular annotation value is translatable text.

In the DCL source code for CDS roles, DDLX source code for metadata extensions, and the DDLA source code for annotation definitions, the syntax check permits only those annotations that follow the rules of an annotation definition. In the DDL source code for data definitions, annotation definitions modify the source code colors and code completion in ADT. Currently, however, they are not covered by the syntax check.


  • The evaluation of the annotations of CDS source code is currently the responsibility of the framework in which the CDS object is used.
  • The methods of the class CL_DD_DDL_ANNOTATION_SERVICE for evaluating annotations of CDS entities return derived and inherited annotations alongside the annotations specified directly in the associated DDL source code.
  • The annotations specified in the DDL source code of a CDS entity can be supplemented or overridden using the annotations of CDS metadata extensions. Here the annotations are specified with the same syntax as in the DDL source code of a CDS entity, with the following restrictions:

  • @< cannot be used for introducing an annotation.

  • There is a set of SAP annotations predefined by SAP, comprising ABAP annotations evaluated by the ABAP runtime environment and framework-specific annotations evaluated by other frameworks. All other annotations are not usually evaluated. It cannot be guaranteed, however, that a framework permits all annotations.
  • The program ABAP_DOCU_CDS_ANNOS_OVERVIEW shows all SAP annotations and their properties.


The following DDL source code for defining a CDS view contains ABAP annotations and other annotations at the allowed positions (in other words, for the entire view, for the elements of the SELECT list, and for an input parameter).

@EndUserText.label: 'Demo View with Annotations'
@AbapCatalog.sqlViewName: 'DEMO_VIEW_ANNOT'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.type: #CLIENT_DEPENDENT

@DemoAnno.vAnnot3:[ 123, 456, 789 ]
@DemoAnno.vAnnot4:{ annot0, annot1:'abc', annot2:123 }
@DemoAnno.vAnnot6:[ { annot0,       annot1:'abc', annot2:123 },  
                    { annot0:false, annot1:'def', annot2:456 } ]
@DemoAnno.vAnnot7:{ annot0,
                    annot1:[ 123, 456, 789 ],
                    annot2:{ annot0, annot1:'abc', annot2:123 } }
define view demo_cds_view_annotations
  with parameters
    @EndUserText.label:'Input Parameter'
    param : syst_uname  
  as select from
      key id   as key_field  
          @EndUserText:{ label:'Some field', quickInfo:'Some info' }
          @DemoAnno.fAnnot3:[ 123, 456, 789 ]
          num1 as some_field  
          @<DemoAnno.fAnnot4:{ annot0, annot1:'abc', annot2:123 }

The ABAP annotations are as follows:

  • EndUserText.label, AbapCatalog.sqlViewName, and ClientHandling.type for the full view
  • EndUserText.label and EndUserText.quickInfo for the element some_field of the SELECT list
  • EndUserText.label and Environment.systemField for the input parameter param.

The remaining annotations are used as examples for framework-specific annotations. An annotation definition that permits the specified annotations shown here could look like this:

@MetadataExtension.usageAllowed: true
define annotation DemoAnno {  
    vAnnot0: Boolean default true;  
    vAnnot1: String(3);  
    vAnnot2: Integer;  
    vAnnot3: array of Integer;  
    vAnnot4: { annot0:Boolean default true;  
    vAnnot5: { annot0:Boolean default true;  
    vAnnot6: array of { annot0:Boolean default true;  
    vAnnot7: { annot0:Boolean default true;  
               annot1: array of Integer;  
               annot2: { annot0:Boolean default true;  
                         annot2:Integer;} };  
    pAnnot1: String(3);  
    pAnnot2: Integer;  
    fAnnot0: Boolean default true;  
    fAnnot1: String(3);  
    fAnnot2: Integer;  
    fAnnot3: array of Integer;  
    fAnnot4: { annot0:Boolean default true;  
               annot2:Integer;} };

The program DEMO_CDS_DDL_ANNOTATIONS access the metadata created by the specified annotations in the database tables DDHEADANNO, DDFIELDANNO, and DDPARAMETERANNO directly and using the methods of the classes CL_DD_DDL_ANNOTATION_SERVICE and CL_DD_DDL_ANALYZE and displays it. Note the following in particular:

  • The annotation @DemoAnno.vAnnot3 is an annotation array consisting of three elements indicated by the indexes $1$, $2$, and $3$.
  • The annotations @DemoAnno.vAnnot4 and @DemoAnno.vAnnot5 show the alternatives to specifying a structured annotation using a comma-separated list in curly brackets and by using structured names.

Unlike the table DDHEADANNO, the tables DDFIELDANNO and DDPARAMETERANNO for the elements and parameters also contain the name of the element or parameter for which an annotation was created.


ABAP CDS - Annotation Syntax, value

ABAP CDS - Annotation Syntax, subannos

ABAP CDS - Annotation Syntax, arrelem

ABAP CDS - Annotation Syntax, .subAnno