SAP CDS ANNOTATIONS - Syntax ARRAY



Get Example source ABAP code based on a different SAP table
  



ABAP_CDS_DDL - Annotation Syntax, arrelem

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

What does it do?
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:
Annotation values value1, value2, ...
Subannotations subannos1, subannos2, ... in curly brackets.
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.



Latest 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.
NON_V5_HINTS
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.
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The following annotation definition is available.
DDLA DEMOANNOSTRINGARRAY
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$.
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
The following annotation definition is available. This is the definition of a structured annotation array.
DDLA DEMOANNOARRAY
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} ]
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
ABAP CDS, Annotation Array
ABAP_EXAMPLE_END