SAP CDS ELEMENT ANNOTATIONS V2



Get Example source ABAP code based on a different SAP table
  


• /at ABAP_CDS_ELEM_AN

ABAP_CDS_DDL - CDS View Entity, SELECT, element_annot

ABAP_SYNTAX
... @annotation ...

What does it do?
Specifies an annotation annotation in the definition of an element of a SELECT list in a CDS view entity as element annotation. Element annotations must be specified before the element they belong to, and the character @ must be placed in front of the name annotation of the annotation.
For CDS view entities, there are strict checks that all element annotations used must be defined as a CDS object in a CDS annotation definition . Otherwise, a syntax error occurs.
All available element annotations are listed in topic element_annot.

ABAP_EXAMPLE_VX5
In the CDS view entity DEMO_SALES_CDS_ELEM_ANNOT, a short text and a tooltip are assigned to the element given_name.
DDLS DEMO_SALES_CDS_ELEM_ANNOT
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
This example demonstrates how element annotations are passed on between views via CDS associations . The following CDS view entity defines and exposes a CDS association _some_assoc:
DDLS DEMO_CDS_ASSOC_ANNO2_VE
A further CDS view entity accesses the view and also exposes the CDS association. Here, the annotation @EndUserText.label is inherited.
DDLS DEMO_CDS_ASSOC_ANNO1_INH_VE
The following CDS view entity defines and exposes its own CDS association _some_assoc. In this case, the CDS annotation @EndUserText.label is not inherited.
DDLS DEMO_CDS_ASSOC_ANNO1_LOC_VE
If the CDS association _some_assoc was exposed from DEMO_CDS_ASSOC_ANNO2_VE instead of or in addition to _some_assoc by specifying the name Demo_Cds_Assoc_Anno2_ve._some_assoc explicitly, the annotation would be inherited again. The class CL_DEMO_CDS_ASSOC_ANNO_VE 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_VE, which means that the result for this CDS association is empty.
ABAP_EXAMPLE_END