SAP CDS PROJ VIEW VIRTEL ABEXA



Get Example source ABAP code based on a different SAP table
  


VX_EXA_ONLY

ABAP_CDS_DDL - CDS Projection View, Calculating a Virtual Element
This example demonstrates how a virtual element is calculated at runtime.

ABAP_SOURCE_CODE
DEMO CL_DEMO_CNSME_BS_PRJ_VIEW_VIRT

ABAP_DESCRIPTION
The example accesses the CDS projection view DEMO_SALES_PV_SO_EXP in which a virtual element expiry_date is bound to an ABAP class CL_DEMO_SALES_VIRT_ELEM_EXIT:
First, it reads data from the view using an ABAP SQL SELECT statement.
Second, it reads data from the view using the service binding DEMO_SB_SALES_PV_SO_EXP. For that, an OData Client Proxy is used, that accesses the OData service of the service binding.
When using ABAP SQL, the class CL_DEMO_SALES_VIRT_ELEM_EXIT is not accessed and the virtual element is not calculated. When using the service binding, the class CL_DEMO_SALES_VIRT_ELEM_EXIT is accessed. When using the OData service, the results of the query are provided by the RAP query engine. The RAP query engine uses ABAP SQL and also calls the method for calculating the virtual element.