CDS Views or CDS Entities can be exposed as OData Services in following ways

  1. The Reference Data Source option in SEGW.
  2. Annotation OData.Publish
  3. RAP Model

In this post, you will learn to map a CDS View to an OData service using The Reference Data Source option in SEGW.

You will need to create a CDS view for this tutorial. Follow below tutorials

  1. Install Eclipse for ABAP Development
  2. Working With Eclipse [1] : Open ABAP Perspective & Create A Project
  3. Introduction to CDS Views

Visit ABAP on HANA series for Tutorials on CDS, AMDP, Eclipse, and ALV IDA.

Create a CDS View

Create New Project and Map CDS

1. Create a project in SEGW.

2. Right-click on Data Model and choose Reference > Data Source

3. Provide CDS View /CDS Entity Name, Click Next

4. CDS Entity Exposed is listed, click Finish

5. Data Source Reference node will show the mapped CDS

Note that there can be only one reference per project.

6. Generate the project

7. Register the service

Testing the Service

Start Gateway client.

HTTP Method : GET
URI : /sap/opu/odata/SAP/ZJP_CDS_SIMPLE_SRV/ZJP_SO_DATA?$format=json
HTTP Method : GET
URI : /sap/opu/odata/SAP/ZJP_CDS_SIMPLE_SRV/ZJP_SO_DATA('109')?$format=json

The Services Based on CDS View / Entities will only have read capability as CDS by itself does not have a CREATE/UPDATE/DELETE functionality.

If we try to force a create operation, it fails with the below error –

Visit OData Development in SAP to explore all articles on OData.


If you like the content, please subscribe…

Join 4,016 other subscribers

Discovering ABAP YouTube Channel