Skip to content

ABAP Keyword Documentation →  ABAP - Dictionary →  ABAP CDS in ABAP Dictionary →  ABAP CDS - Annotations →  ABAP CDS - SAP Annotations →  ABAP CDS - Framework-Specific Annotations →  ABAP CDS - Framework-Specific Annotation Syntax 

ABAP CDS, Annotation Array

This example shows how an annotation array is evaluated in a piece of DDL source code.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    cl_dd_ddl_analyze=>get_annotations(
      EXPORTING ddlnames = VALUE #( ( 'DEMO_CDS_ANNOTATION_ARRAY' ) )
                leaves_only = abap_true
      IMPORTING
                fieldannos  = DATA(annos) ).
    cl_demo_output=>display( annos ).

Description

The program reads the element annotations of the following CDS view:

@AbapCatalog.sqlViewName: 'DEMO_CDS_ANNOARR'
define view demo_cds_annotation_array
  as select from
    demo_expressions
    {
      @Consumption.filter.hierarchyBinding:
         [ { type: '...', value: '...', variableSequence: 1 },
           { type: '...', value: '...', variableSequence: 2 } ]
      id
    }

An annotation array Consumption.filter.hierarchyBinding with two elements is assigned to the view field ID and each of the elements is structured using three subannotations type, value, and variableSequence.

The annotation array is a subannotation of a framework-specific annotation delivered by SAP and defined as follows in its annotation definition:

annotation Consumption
{

   ...

   filter
   {

      ...

      hierarchyBinding : array of
      {
          type: String(12) enum { ELEMENT;
                                  PARAMETER;
                                  CONSTANT;
                                  USER_INPUT;
                                  SYSTEM_FIELD; };
         value : String(512);
         variableSequence : Integer;
      };
   };
};

In the case of elements of the annotation array, square brackets are specified in the tabular list of the framework-specific annotations. These brackets are used as placeholders for the $ signs used in the internal metadata repository, which enclose the serial index of an array element.