Ansicht
Dokumentation

ABENCDS_ANNOTATIONS_SYNTAX - CDS ANNOTATIONS SYNTAX

ABENCDS_ANNOTATIONS_SYNTAX - CDS ANNOTATIONS SYNTAX

rdisp/max_wprun_time - Maximum work process run time   General Data in Customer Master  
This documentation is copyright by SAP AG.
SAP E-Book

- Annotation Syntax

@$[$]Anno$[: value $]
       $|$[: { subannos } $]
       $|$[: [ arrelem ] $]
       $|$[.subAnno$[ ... $]$]


Effect

A CDS annotation is specified in CDS source code by using fixed annotation syntax. This syntax specifies the following:

  • The annotation is introduced using the character @ or the characters @.
@ can be used in the CDS DDL for CDS entities except for CDS view entities in order to specify the annotation after a list element in a comma-separated or semicolon-separated list.
  • A main annotation Anno consisting of letters, numbers, and underscores and starting with a letter. A main annotation that is not structured using subannotations can be specified exactly once in a scope.
  • One of the following optional alternatives specified after a colon (:):

  • The main annotation Anno chained with a subannotation subAnno using a period (.). The combination Anno.subAnno is a structured annotation name that can be extended using further subannotations.

An annotation name must be unique within a scope. Only those annotations should be specified for which a CDS annotation definition exists. Alongside the syntax rules above, the annotation definition also specifies the following:

  • The annotations of an annotation definition specify the scope of the annotation, whether it can be moved to metadata extensions, and whether a particular annotation value is translatable text.

In the DCL source code for CDS roles, DDLX source code for metadata extensions, and the DDLA source code for annotation definitions, the syntax check allows only those annotations that follow the rules of an annotation definition. In the DDL source code for data definitions, annotation definitions modify the source code colors and code completion in ADT. Currently, however, they are not covered by the syntax check.

Notes

  • The evaluation of the annotations of CDS source code is currently the responsibility of the framework in which the CDS object is used.
  • The annotations specified in the DDL source code of a CDS entity can be supplemented or overridden using the annotations of CDS metadata extensions. Here the annotations are specified with the same syntax as in the DDL source code of a CDS entity, with the following restrictions:
  • @ cannot be used for introducing an annotation.

  • There is a set of SAP annotations predefined by SAP, comprising ABAP annotations evaluated by the ABAP runtime framework and framework-specific annotations evaluated by other frameworks. All other annotations are not usually evaluated. It cannot be guaranteed, however, that a framework allows all annotations.

Example

The following DDL source code for defining a CDS view contains ABAP annotations and other annotations at the allowed positions (in other words, for the entire view, for the elements of the SELECT list, and for an input parameter).

The ABAP annotations are:

  • EndUserText.label, AbapCatalog.sqlViewName, and ClientHandling.type for the full view
  • EndUserText.label and EndUserText.quickInfo for the element some_field of the SELECT list
  • EndUserText.label and Environment.systemField for the input parameter param.

The remaining annotations are used as examples for framework-specific annotations. An annotation definition that allows the specified annotations shown here could look like this:

The program DEMO_CDS_DDL_ANNOTATIONS access the metadata created by the specified annotations in the DDIC database tables DDHEADANNO, DDFIELDANNO, and DDPARAMETERANNO directly and using the methods of the classes CL_DD_DDL_ANNOTATION_SERVICE and CL_DD_DDL_ANALYZE and displays it. Note the following in particular:

  • The annotation @DemoAnno.vAnnot3 is an annotation array consisting of three elements indicated by the indexes $1$, $2$, and $3$.
  • The annotations @DemoAnno.vAnnot4 and @DemoAnno.vAnnot5 show the alternatives to specifying a structured annotation using a comma-separated list in curly brackets and by using structured names.

Unlike the table DDHEADANNO, the tables DDFIELDANNO and DDPARAMETERANNO for the elements and parameters also contain the name of the element or parameter for which an annotation was created.






Fill RESBD Structure from EBP Component Structure   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

Length: 13333 Date: 20240426 Time: 200720     sap01-206 ( 133 ms )