SAP CDS ELEMENT ANNOTATIONS PV



Get Example source ABAP code based on a different SAP table
  


• /at ABAP_CDS_ELEM_AN_PV

ABAP_CDS_DDL - element_annot, Transactional Query

ABAP_SYNTAX
... @annotation ...

What does it do?
Specifies an annotation annotation in the definition of an element of a projection list in a CDS projection view 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 projection views, 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.

Propagation of Element Annotations in CDS Projection Views
Projected elements and exposed associations from the projected entity inherit the element annotations from the projected entity. Any annotations defined in the projected CDS entity cds_entity at element level are passed to the CDS projection view projection_view . This means that the CDS projection view has the same annotation values as the projected entity . Only if an annotation is defined explicitly for the same element in the CDS projection view, the values are overwritten and only the new values are valid for the element in question. Framework-specific annotations can be used to give the element specific semantic properties for other SAP frameworks. ABAP_CAUTION If you use an annotation with an element reference ElementRef in the projected entity and the reference element is aliased in the projection entity, the reference is not drawn to the element in the projection view, due to the name change. In such a case, you have to redefine the annotation in the projection view and use the alias name of the element in the annotation value. ABAP_EXCEPTION In an analytical projection view, the annotation Aggregation.default that defines an analytical measure is inherited from the projected entity and it cannot be overwritten.
If a field is not directly projected but used in an expression or built-in function, element annotations are not inherited. ABAP_EXCEPTION If a field is used in the CAST PRESERVING TYPE expression, element annotations are inherited.
Inheritance of element annotations can be switched off by using the header annotation @Metadata.ignorePropagatedAnnotations.

ABAP_EXAMPLE_VX5
The CDS projection view DEMO_SALES_PV_SO_I_LIST is a projection of the CDS view DEMO_SALES_CDS_SO_I. Even though the projected entity uses a semantics annotation to connect the gross amount to the currency and the quantity field to the respective unit, the projection view repeats these annotations. This is required because of the alias name of the currency and unit fields.
ABAP_EXAMPLE_END