Skip to content

ABAP Keyword Documentation →  ABAP - Dictionary →  ABAP CDS in ABAP Dictionary →  ABAP CDS - Annotations →  ABAP CDS - Definition of Annotations →  ABAP CDS - DDL for Annotation Definitions 


Other versions: 7.31 | 7.40 | 7.54


[define] annotation Anno {  :   type; }
                       | { [:] {subannos}[;] }
                       | {  :   array of arrelem }


The statement define annotation defines a CDS annotation with the name Anno in the CDS DDL in the DDLA source code. The annotation Anno is the main annotation of the current annotation definition, which can be structured with optional subannotations. The DDLA source code of an annotation definition can contain the definition of exactly one main annotation, whose name must match the name of the DDLA source code. The names are case-sensitive. Annotations of the definition annotation, @annotation_annot1, @annotation_annot2, ..., can be specified before the statement define annotation. These are inherited by subannotations or overwritten there.

The statement define annotation creates the annotation Anno as a CDS object, which is transported using the DDLA source code. The definition of the annotation Anno describes how it is to be used in other CDS source code in annotation syntax:

  • Anno is the name of the annotation. It can contain letters, numbers, and underscores, and must start with a letter. Only annotations with names defined in this way should be used.
  • One of the following must be specified after the name:
  • A colon (:) followed by the definition of the type type of the annotation. Enumerations and a default value can be defined when the type is specified. The type specification must be closed using a (;).
  • An optional colon (:) followed by the structuring of the annotation using subannotations subannos in curly brackets {...}. This can be closed using an optional semicolon (;).
  • A colon (:) followed by the definition of the elements of an array using array of. This makes the annotation Anno into an annotation array of the elements defined using arrelem. These elements can be a type specification or subannotations.


  • Put simply, an annotation definition dictates how the annotation needs to be specified in CDS source code in annotation syntax. When annotations are specified, the annotation definitions are used for the color of the source code and for code completion.

  • The type specification determines which annotation values can be specified in the annotation syntax when the annotation is used.

  • Alongside the rules defined by the statement define annotation, an annotation definition also has annotation documentation that describes its meaning and how it is used by the framework in question.


Defines a structured annotation. The main annotation DemoAnnoStruct has subannotations subAnno1 to subAnno4. The subannotations subAnno3 and subAnno4 are annotation arrays. (Here, subAnno4 is structured.)

@Scope:[#VIEW, #EXTEND_VIEW]  
define annotation DemoAnnoStruct  
  { subAnno1 : Boolean default true;  
    subAnno2 : Integer enum { I1; I2; I3; } default #I1;  
    subAnno3 : array of String(10);  
    subAnno4 : array of { comp1 : String(1);  
                          comp2 : String(2);  

The annotation defined in this way permits the following to be specified in annotation syntax in a piece of DDL source code that defines a CDS view or a CDS table function as a view annotation or as a function annotation:

  • Specifies the subannotation subAnno1 once (the default value true is used here implicitly):
  • Specifies the subannotations subAnno1 and subAnno2 together in curly brackets (the default values are overwritten by explicit annotation values here. In subAnno2, one of the fixed enumeration values is used:
@DemoAnnoStruct:{subAnno1:false, subAnno2:#I2}
  • Specifies annotation values for the annotation array subAnno3. The values within the quotation marks can have a maximum of ten characters:
  • Specifies annotation values for the structured annotation array subAnno4.
@DemoAnnoStruct.subAnno4:[ {comp1: 'a', comp2: 'b' },
                           {comp1: 'c', comp2: 'd' },
                           {comp1: 'e', comp2: ‘f' } ]


ABAP CDS - DEFINE ANNOTATION, annotation_annot