Get Example source ABAP code based on a different SAP table
ABAP_CDS_DDL - DEFINE ANNOTATION>, subannos>
ABAP_SYNTAX ... $[@annotation_annot1>$] $[@annotation_annot2>$] ... subAnno1${:type> ;$}$|${$[:$]{subannos}$[;$]$}$|${:array of arrelem>$}; $[@annotation_annot1>$] $[@annotation_annot2>$] ... subAnno2${:type> ;$}$|${$[:$]{subannos}$[;$]$}$|${:array of arrelem>$}; ...>
What does it do? Structures a CDS annotation> using subannotations> subAnno1>, subAnno2>, ... . The subannotations are defined in a semicolon-separated list in curly brackets { ... }> in the statement define annotation>> (a semicolon must be placed after the final entry in the list too). The names of the subannotations of an annotation must be unique. Each subannotation is specified using the same syntax as when the main annotation> is specified after define annotation>>. This means the following:
The name of the subannotation can contain letters, numbers, and underscores only and must start with a letter.
type>> can be used to define the possible annotation value> for a subannotation
A subannotation can itself be structured using further subannotations subannos>
A subannotation can be defined as an annotation array> of array elements arrelem>> using array of> Annotation definition annotations @annotation_annot1>>, @annotation_annot2>>, ... can be specified in front of each subannotation. These annotations override any identically named annotation definition annotations specified for the structured annotation itself. Any annotations not specified directly in front of a subannotation are inherited by the next higher annotation in the hierarchy.
Latest notes:
Colons (:>) in front of the opening curly bracket and semicolons ( ;>) after the closing curly structuring bracket { ... }> are optional.
In the annotation syntax>, structured annotations are specified either using comma-separated lists in curly brackets> or using structured names>. ABAP_HINT_END
ABAP_EXAMPLE_VX Defines a structured main annotation> DemoAnnoMain> with three subannotations>, two of which are themselves structured. The semicolons after the closing curly structuring brackets are omitted here. DDLA DEMOANNOMAIN The annotation can be used, for example, as followed in CDS source code: @DemoAnnoMain: {subAnno1:true, subAnno2:{subsubAnno1:'X', subsubAnno2:100}, subAnno3:{subsubAnno1:'Y', subsubAnno2:200} }> The exact same result can be achieved as follows: @DemoAnnoMain.subAnno1:true @DemoAnnoMain.subAnno2.subsubAnno1:'X' @DemoAnnoMain.subAnno2.subsubAnno2:100 @DemoAnnoMain.subAnno3.subsubAnno1:'Y' @DemoAnnoMain.subAnno3.subsubAnno2:200> ABAP_EXAMPLE_END