Skip to content

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

ABAP CDS - Annotation Syntax, arrelem

Other versions: 7.31 | 7.40 | 7.54

Syntax

...  value1| {subannos1},
     value2| {subannos2},
     ...

Effect

Comma-separated list of array elements in the square brackets of an annotation. This makes the annotation specified in front of the colon into an annotation array with the elements specified in the brackets. The possible elements of an array are:

Arrays are not intended to be nested directly and one element in an array represents an annotation to which the same rules apply as to single annotations. The difference is that an array element does not have an explicit name. In the internal repository of the metadata defined by an annotation, however, an array element is identified uniquely using an index appended to the name of the array. This makes it possible to find the array element when it is evaluated.

Array elements should only be specified for annotations for which this is noted in the associated annotation definition.


Notes

  • Annotation arrays with elements of different types and categories can be specified in the syntax of the DDL for data definitions. Arrays of this type are not supported in annotation definitions. Square brackets for annotation arrays can be nested directly in data definitions. The nesting of arrays is also not supported in annotation definitions. The internal metadata repository counts the nested arrays when indexing the elements, but otherwise they are ignored. They are not returned by evaluations of the annotations based on this metadata.

  • Only annotations indicated as annotation arrays by the square brackets are indexed internally and can be found as array elements in evaluations. If an annotation @Annot is defined as an annotation array in its annotation definition but specified as @Annot: value instead of @annot: [value] in CDS source code, it is not handled as an annotation array.

Example

The following annotation definition is applied.

@Scope:[#VIEW, #EXTEND_VIEW]  
define annotation  
  DemoAnnoStringArray: array of String(1);

The annotation can then, for example, be specified as follows:

@DemoAnnoStringArray:[ 'a', 'b', 'c' ]

The annotation array has three elements, each of which is assigned a suitable annotation value. Evaluating the annotation using the method GET_DIRECT_ANNOS_4_ENTITY of the class CL_DD_DDL_ANNOTATION_SERVICE produces the following

ANNONAME VALUE
DEMOANNOSTRINGARRAY$1$ 'a'
DEMOANNOSTRINGARRAY$2$ 'b'
DEMOANNOSTRINGARRAY$3$ 'c'

The elements are indicated using the indexes $1$, $2$, and $3$.


Example

The following annotation definition is applied. This is the definition of a structured annotation array.

@Scope:[#VIEW, #EXTEND_VIEW]
define annotation  
  DemoAnnoArray: array of { subAnno1: Integer;  
                            subAnno2: Integer;  
                            subAnno3: Integer; }

The annotation can then, for example, be specified with four structured array elements as follows:

@DemoAnnoArray:[ {subAnno1:11, subAnno2:12, subAnno3:13},
                 {subAnno1:21, subAnno2:22, subAnno3:23},
                 {subAnno1:31, subAnno2:32, subAnno3:33},
                 {subAnno1:41, subAnno2:42, subAnno3:43} ]

Executable Example

ABAP CDS, Annotation Array