SAP DDIC REPLACEMENT OBJECT ABEXA



Get Example source ABAP code based on a different SAP table
  


VX_EXA_ONLY

ABAP_DDIC - Replacement Object for Database Table
This example demonstrates a DDIC database table with a replacement object.

ABAP_SOURCE_CODE
DEMO CL_DEMO_TABLE_RPLCMNT_OBJECT

ABAP_DESCRIPTION
This class accesses two DDIC database tables, DEMO_SUMDIST_AGG and DEMO_SUMDIST. These tables are identical except for the fact that the CDS view DEMO_CDS_SUMDIST is defined as a replacement object for DEMO_SUMDIST.
The DDIC database table DEMO_SUMDIST_AGG is filled with aggregated data (done here in the static constructor of the class demo). When DEMO_SUMDIST is accessed, the replacement object performs exactly the same aggregation:
DDLS DEMO_CDS_SUMDIST
Both similar accesses to the DDIC database tables produce the same results, which is verified using the statement ASSERT .
A third SELECT statement accesses the CDS view DEMO_CDS_SUMDIST directly. To produce the same result set as when accessing the DDIC database tables, a client column must be added, since the result set of a client-dependent CDS view does not contain a client column.
A DDIC database view DEMO_SUMDIST_OBS contains the DDIC database table DEMO_SUMDIST as a basis table. There is no redirect to the replacement object of DEMO_SUMDIST in a SELECT. A DDIC database view DEMO_SUMDISTVIEW that is otherwise similar has the following CDS view as a replacement object:
DDLS DEMO_CDS_SUMDISTVIEW
This view accesses the replacement object of the DDIC database table DEMO_SUMDIST. When DEMO_SUMDISTVIEW is accessed using SELECT, its replacement object is evaluated and the result again matches the preceding result.