SAP CDS SEMANTICS ANNOTATION ABEXA



Get Example source ABAP code based on a different SAP table
  


VX_EXA_ONLY

ABAP_CDS , Evaluation of Annotations
This example demonstrates how semantics annotations of DDL source code are evaluated.

ABAP_SOURCE_CODE
DEMO CL_DEMO_CDS_SEMANTICS_ANNTTN

ABAP_DESCRIPTION
This class uses a simple example to show how annotations can be evaluated in a framework. All rows in a CDS entity are to be found that do not contain a fully specified address. Here, a fully specified address is simply a set of elements for name, street, city, postal code, and country, none of which can be empty.
To do this, the class uses cl_dd_ddl_annotation_service=>get_drct_annos_4_entity_elmnts to read the element annotations of a CDS entity and gets the names of the elements defined (using semantics annotations) as the required components of an address in the internal table address_components. In the next step, the CDS entity is read using SELECT and a dynamic ASSIGN statement is used to check whether all required elements have a non-initial value for each read row. The output consists of any rows that do not contain a full address.
The following CDS view entity is used as an example for a CDS entity:
DDLS DEMO_CDS_SEMANTICS_ANNOTATION
This view wraps the DDIC database table SCUSTOM, which contains address data. The assignment of the semantics annotations to the columns of the DDIC database table gives the columns semantics that can be evaluated. Previously, this was only provided by those names and DDIC data elements that are no longer relevant for the evaluation depicted here.