SAP CDS READING



Get Example source ABAP code based on a different SAP table
  


SAP_ONLY
VERSION 5 OUT
• CL_DD_CDS_READ_API_FACTORY ABAP_SYSTEM_CDS

ABAP_CDS - Read API
When a CDS entity defined in CDS source code is activated, the CDS metadata is stored in internal system tables. This metadata can be evaluated using methods of the interface IF_DD_CDS_READ_API_ENTITY. This interface can be instantiated using the method CREATE of the system class CL_DD_CDS_READ_API_FACTORY.
IF_DD_CDS_READ_API_ENTITY contains methods for evaluating properties common to all CDS types. For more specific information, the interface must be cast to a subordinate interface IF_DD_CDS_READ_API_*.
ABAP_NOTE When downcasting IF_DD_CDS_READ_API_ENTITY to a more specific type, the target interface must match the type of entity. For example, casting a CDS view entity to the interface IF_DD_CDS_READ_API_HIERARCHY is not possible. CDS table functions do not support associations and must not be cast to IF_DD_CDS_READ_API_ASSOCIATONS. An invalid downcast raises a catchable exception of the class CX_SY_MOVE_CAST_ERROR.



Latest notes:

The methods of the class CL_DD_CDS_READ_API_FACTORY replace the class CL_DD_SOBJECT_FACTORY, which is the predecessor of the CDS Read API and was used to read the metadata of CDS DDIC-based views.
IF_DD_CDS_READ_API_ENTITY and CL_DD_CDS_READ_API_FACTORY are not released under any release contract. They can be used internally at SAP only.
NON_V5_HINTS
ABAP_HINT_END
VX_EXA_ONLY

ABAP_EXAMPLE_VX
Evaluating the metadata of a CDS view entity. The method CREATE of the class CL_DD_CDS_READ_API_FACTORY returns an interface variable of the static type IF_DD_CDS_READ_API_ENTITY pointing to an instance of the class. Using methods of the interface IF_DD_CDS_READ_API_ENTITY and casts to other interfaces, the client dependency, base objects, associations, association ON condition, and elements of the CDS view entity DEMO_CDS_ASSOCIATION_VE are evaluated.
ABEXA 01757
ABAP_EXAMPLE_END
VX_EXA_ONLY

ABAP_EXAMPLE_VX
Evaluating the metadata of a CDS hierarchy. The method CREATE of the class CL_DD_CDS_READ_API_FACTORY returns an interface variable of the static type IF_DD_CDS_READ_API_ENTITY pointing to an instance of the class. Using methods of the interface IF_DD_CDS_READ_API_ENTITY and casts to other interfaces, the base objects, fields, and other attributes of the CDS hierarchy DEMO_CDS_SIMPLE_TREE are evaluated.
ABEXA 01758
ABAP_EXAMPLE_END