How to create OData service for ABAP CDS views using Referenced Data Source in SEGW


Hello everyone, in this blog we will discuss on how to create OData service for ABAP CDS views in SEGW based on Referenced Data Source.

In previous blog How to create OData service for ABAP CDS Views we have seen an easy approach on exposing the ABAP CDS view as an OData service using the annotation @OData.publish: true and also the restrictions/disadvantages by following the approach.

Referenced Data Source

To overcome the above restriction, we can follow this approach. Below are the features supported.

Advantages and Features Supported

  • Multiple Entities i.e multiple CDS views
  • Associations
  • Actions using Function Imports in SEGW
  • CDS View with parameters
  • CDS annotations considered and derived at runtime
  • CDS changes will be reflected at runtime, no need for re-activation


Basic understating of ABAP CDS views, to know more click here.

Step-by-Step Procedure

1. Creating an New Project

Launch SEGW – Gateway Service Builder transaction on front-end server(FES).

Click on Create Project and provide the necessary details on Create Project dialog box.Create New Project in SEGW

A new SEGW project will be created with empty data model like below.Create New Project in SEGW 1

1.2. Reference Data Source

Now right-click on the Data Model choose Reference and then Data Source.Data Source Reference in SEGW

A new Reference Data Source wizard will open like below. Choose ABAP CDS view using the F4 help and hit Next.Data Source Reference in SEGW 1

In the next wizard step check the information and hit Finish.Data Source Reference in SEGW 2

ABAP CDS entity will be successfully referenced in the SEGW project and new folder Data Source References will be created under Data Model folder.Data Source Reference in SEGW 3

Entity types, Entity Sets and Associations will automatically created for the ABAP CDS view.Data Source Reference in SEGW 4

You can further explore the properties and other artifacts created.

2. Generating Model Provider Class/Data Provider Class and Other Runtime Objects

Navigate and select the project node and hit Generate Runtime Objects button to generate the SEGW OData service run-time artifacts.

On Model and Service Definition dialog box, a list of classes is shown and will be generated. You can go with default name or change them if you like to give different names and hit OKGenerate Runtime Objects in SEGW

On the Create Object Directory Entry dialog box, enter a value (e.g. $TMP) to the Package field, and then choose Save.

Now the service classes are generated.

3. Activating Service

Launch the transaction /IWFND/MAINT_SERVICE – Activate and Maintain Services.

Choose Add Service.Activate Service in SEGW

On Add Selected Service screen provide the value for System Alias field and then choose Enter. A list of services is then displayed.

From the list of services choose the relevant service, you can search based on your project name. Click on Add Selected ServicesActivate Service in SEGW 1

On Add Service dialog box specify the package name and choose Enter.Activate Service in SEGW 2

Service is successfully activated with message dialog box like below.Activate Service in SEGW 3

Go back to the Activate and Maintain Services screen and filter with service we just created above. Choose SAP Gateway Client.Test Service in Gateway Client 1

4. Test Service in Gateway Client

On SAP Gateway Client, choose Execute to view the metadata of the OData service.Test Service in Gateway Client 2

Navigate to EntitySets button from the application toolbar and choose the entity set.Test Service in Gateway Client 3

Choose Execute to view the data retrieved from the ABAP CDS view.Test Service in Gateway Client 4

Congrats..! You have successfully created an OData service for ABAP CDS view using SEGW based on SADL framework. Please stay tuned for ABAP CDS View Tutorials.


Leave a comment in the below comment section and let us know your feedback.

Comments are closed.