Skip to content

ABAP Keyword Documentation →  ABAP - Dictionary →  ABAP CDS in ABAP Dictionary →  ABAP CDS - Data Definitions →  ABAP CDS - DDL for Data Definitions →  ABAP CDS - DEFINE VIEW →  ABAP CDS - SELECT →  ABAP CDS - SELECT, select_list →  ABAP CDS - SELECT, element 

ABAP CDS - SELECT, element_annot

Other versions: 7.31 | 7.40 | 7.54

Syntax

... @annotation ...
... @<annotation ...

Effect

Specifies an annotation annotation in the definition of an element of a SELECT list in a CDS view as element annotation. Element annotations can be specified before and after the element.

  • In front of the element, the character @ must be placed before the name annotation of the annotation.
  • Following the element, the characters @< must be placed before the name annotation of the annotation.

The elements of CDS entities can be assigned to the element annotations grouped under element_annot.


Example

In the CDS view corporation_sales_order, a short text and a tooltip are assigned to the element role. The element currency_code is flagged as a currency key and is assigned as a currency key to the element gross_amount.

@AbapCatalog.sqlViewName: 'CORP_SO_VW'
define view corporation_sales_order as
  select from snwd_bpa as business_partner
           inner join snwd_so as sales_order
             on business_partner.node_key = sales_order.buyer_guid
         { key sales_order.so_id as sales_order_id,
               business_partner.bp_id as corporation_id,
               business_partner.company_name,
              @EndUserText.label: 'Corporation Role'
              @EndUserText.quickInfo: 'Customer or supplier'
                 business_partner.bp_role as role,
              @Semantics.currencyCode
                 sales_order.currency_code,
              @Semantics.amount.currencyCode: 'currency_code'
                 sales_order.gross_amount }
         where business_partner.legal_form = 'Inc.'; //Corporations only


Example

This example demonstrates inheritance of the element annotations in publications of CDS associations. The following CDS view defines and publishes a CDS association _some_assoc:

@AbapCatalog.sqlViewName: 'DEMO_CDS_ASAN2'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view Demo_Cds_Assoc_Anno2
  as select from
    demo_join2
    association [*] to demo_join3 as _some_assoc on
      _some_assoc.l = demo_join2.d
    {
      @SomeAnno: 'Association to demo_join3'
      _some_assoc,
      d
    }

A further CDS view accesses the view and also publishes the CDS association. Here, the annotation @SomeAnno is inherited.

@AbapCatalog.sqlViewName: 'DEMO_CDS_ASAN1I'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view Demo_Cds_Assoc_Anno1_Inh
  as select from
    Demo_Cds_Assoc_Anno2
    {
      _some_assoc,
      d
    }

In the following CDS view, on the other hand, the dedicated CDS association _some_assoc is published and the annotation is not inherited.

@AbapCatalog.sqlViewName: 'DEMO_CDS_ASAN1L'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view Demo_Cds_Assoc_Anno1_Loc
  as select from
    Demo_Cds_Assoc_Anno2
    association [*] to demo_join1 as _some_assoc on
      Demo_Cds_Assoc_Anno2.d = _some_assoc.d
    {
      _some_assoc,
      d
    }

If the CDS association _some_assoc were published from Demo_Cds_Assoc_Anno2 instead of or in addition to _some_assoc by specifying the name Demo_Cds_Assoc_Anno2._some_assoc explicitly, the annotation would be inherited again. The program DEMO_CDS_ASSOC_ANNO evaluates the annotations of both views. No local element annotations are defined for the locally defined association _some_assoc of the view Demo_Cds_Assoc_Anno1_Loc, which means that the result for this CDS association is empty.