SAP CDS META DATA EXTENSION EVAL



Get Example source ABAP code based on a different SAP table
  



ABAP_CDS - Evaluation of Metadata Extensions
When evaluating annotations with the class CL_DD_DDL_ANNOTATION_SERVICE , the annotations from metadata extensions are considered first. If there are different metadata extensions for the same CDS entity, priority is determined by the following criteria:
BEGIN_SECTION SAP_ONLY
CDS variant
A metadata extension can be assigned a CDS variant in its definition with ANNOTATE with the addition VARIANT.
The name of a CDS variant can be transferred to the methods of the class CL_DD_DDL_ANNOTATION_SERVICE to select the metadata extension.
END_SECTION SAP_ONLY
Layer of metadata extension The layer of a metadata extension is defined in its definition with ANNOTATE by the annotation @Metadata.layer. These are the enumeration symbols for layers, in descending order of priority:
#CUSTOMER
#PARTNER
#INDUSTRY
#LOCALIZATION
#CORE
The methods of the class CL_DD_DDL_ANNOTATION_SERVICE collect the annotations they have returned, depending on the variant and the layers, according to the following hierarchy: The annotations are evaluated according to the layer defined by the annotation @Metadata.layer. Annotations found in a higher layer are no longer searched for in a lower layer, so any annotation that exists there is overridden. Then, the annotations of the CDS entity itself that are not found in a metadata extension are added as well. These can be annotations from the source code and inherited annotations. For annotations inherited from other CDS entities, any metadata extensions are evaluated first, according to the hierarchy described above.
If there are several metadata extensions in a layer, the annotations of the first metadata extension to be found are used. The metadata extensions are evaluated according to an undefined but stable order.

ABAP_EXAMPLE_ABEXA
CDS Metadata Extensions with CDS Variants
ABAP_EXAMPLE_END