Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Andre_Fischer
Product and Topic Expert
Product and Topic Expert
Today I was asked how to retrieve the name or the names of CDS views being used by OData Services that have been published either using autoexposure leveraging the annoation OData.publish:true or using the Referenced Data Source approach.

Autoexposure:


If the service has been published using OData.publish: true the answer is quite simple because the technical Service name is derived by the SADL Framework from the name of the underlying CDS view by adding the Suffix _CDS.

An OData service with the name: ZS4H_C_SLSORDER_TP_CDS is thus based on the CDS view ZS4H_C_SLSORDER_TP.

Referenced Data Source:


In this case the service name is derived from the SEGW project name and typically ends with _SRV.

Though the project name in SEGW and hence the service name can be chosen freely, the names of the entity sets are equivalent to the names of the underlying CDS views.

(This is also true for OData services being created using Autoexposure => OData.publish: true)

A service called ZDX271_20_SRV having entity sets called

  • SEPM_I_BusinessPartner_E

  • Sepm_I_SalesOrdOverallStatus

  • Zdx271_C_Slsorder_20

  • Zdx271_C_Slsorderitem_20


would be based on CDS views having those four aforementioned names.

To get the names of the Entity sets there are two options:

 

  • You can search for the service name using the catalogue Service


Run the following URL in the SAP Gateway Client:
/sap/opu/odata/IWFND/CATALOGSERVICE;v=2/ServiceCollection?search='ZDX271_20_SRV'

Here you will find one entry
<id>http://<host>:<port>/sap/opu/odata/IWFND/CATALOGSERVICE;v=2/ServiceCollection('ZDX271_20_SRV_0001')</id>

having an entity set called "EntitySets"
/sap/opu/odata/IWFND/CATALOGSERVICE;v=2/ServiceCollection('ZDX271_20_SRV_0001')/EntitySets

that would list the entity sets and thus the names of the CDS views of your OData service.

 

  • Or if you know the Service URL you can simply retrieve the service document


 

by using the following URL:

/sap/opu/odata/sap/ZDX271_20_SRV/?$Format=XML

that contains the names of the Entity sets
<app:workspace>

<atom:title type="text">Data</atom:title>

<app:collection href="SEPM_I_BusinessPartner_E" sap:content-version="1" sap:deletable="false" sap:updatable="false" sap:creatable="false">
<atom:title type="text">SEPM_I_BusinessPartner_E</atom:title>
<sap:member-title>EPM Demo: BuPa with External IDs</sap:member-title>
</app:collection>

<app:collection href="Sepm_I_SalesOrdOverallStatus" sap:content-version="1" sap:deletable="false" sap:updatable="false" sap:creatable="false">
<atom:title type="text">Sepm_I_SalesOrdOverallStatus</atom:title>
<sap:member-title>EPM Demo: Sales Order Overall Status</sap:member-title>
</app:collection>

<app:collection href="Zdx271_C_Slsorder_20" sap:content-version="1" sap:deletable="false" sap:updatable="false" sap:creatable="false">
<atom:title type="text">Zdx271_C_Slsorder_20</atom:title>
<sap:member-title>Sales Order Header Consumption View #20</sap:member-title>
</app:collection>

<app:collection href="Zdx271_C_Slsorderitem_20" sap:content-version="1" sap:deletable="false" sap:updatable="false" sap:creatable="false">
<atom:title type="text">Zdx271_C_Slsorderitem_20</atom:title>
<sap:member-title>Sales Order Item Consumption View #20</sap:member-title>
</app:collection>

</app:workspace>

 

Please note:

It will become tricky to find the names of the CDS views if someone has renamed the entity sets in the MPC_EXT class as I have described in another thread.

 

Hope this helps,

Andre

 
1 Comment