Hello everyone, in this blog we will discuss on how to create OData service for ABAP CDS views in SEGW transaction.
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.
To overcome the above restriction, we can follow this approach. Below are the features supported.
Advantages and Features Supported
- Multiple Entities
- 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
Prerequisites
Basic understating of ABAP CDS views, to know more click here.
Step-by-Step Procedure
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.
- A new SEGW project will be created with empty data model like below.
Reference Data Source
- Now right-click on the Data Model choose Reference and then Data Source.
- A new Reference Data Source wizard will open like below. Choose ABAP CDS view using the F4 help and hit Next.
- In the next wizard step check the information and hit Finish.
- ABAP CDS entity will be successfully referenced in the SEGW project and new folder Data Source References will be created under Data Model folder.
- Entity types, Entity Sets and Associations will automatically created for the ABAP CDS view.
- You can further explore the properties and other artifacts created.
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 OK
- 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.
Activating Service
- Launch the transaction /IWFND/MAINT_SERVICE – Activate and Maintain Services.
- Choose Add Service.
- 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 Services
- On Add Service dialog box specify the package name and choose Enter.
- Service is successfully activated with message dialog box like below.
- 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
- On SAP Gateway Client, choose Execute to view the metadata of the OData service.
- Navigate to EntitySets button from the application toolbar and choose the entity set.
- Choose Execute to view the data retrieved from the ABAP CDS view.
Congrats..! You have successfully created an OData service for ABAP CDS view using SEGW based on SADL framework.
The post How to create OData service for ABAP CDS views in SEGW appeared first on SAP Fiori,SAP HANA,SAPUI5,SAP Netweaver Gateway Tutorials,Interview Questions|SAP Learners.