Ansicht
Dokumentation

ABENCDS_F1_DEFINE_ANNOTATION - CDS F1 DEFINE ANNOTATION

ABENCDS_F1_DEFINE_ANNOTATION - CDS F1 DEFINE ANNOTATION

CL_GUI_FRONTEND_SERVICES - Frontend Services   General Material Data  
This documentation is copyright by SAP AG.
SAP E-Book

- DEFINE ANNOTATION

$[@annotation_annot1$]
$[@annotation_annot2$]
...
$[define$] annotation Anno ${  : type; $}
                       $| ${ $[:$] {subannos}$[;$] $}
                       $| ${  :   array of arrelem $}


Effect

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.

Notes

  • Put simply, an annotation definition specifies 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.

Example

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.)

The annotation defined in this way allows 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 (CDS view entity, CDS projection view, ) or as a function annotation:

  • Specifies the subannotation subAnno1 once (the default value true is used here implicitly):
@DemoAnnoStruct.subAnno1
  • 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 enumerated 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:
@DemoAnnoStruct.subAnno3:['a','abc','abcdefghij']
  • Specifies annotation values for the structured annotation array subAnno4.
@DemoAnnoStruct.subAnno4:[ {comp1: 'a', comp2: 'b' },
                           {comp1: 'c', comp2: 'd' },
                           {comp1: 'e', comp2: 'f' } ]







RFUMSV00 - Advance Return for Tax on Sales/Purchases   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.

Length: 12724 Date: 20240329 Time: 081752     sap01-206 ( 131 ms )