Creating OData Service based on Referenced Data Source using SADL framework
This blog post will provide the steps to implement an OData service using SADL framework and how to reference an SAP ABAP CDS view in SEGW Gateway Builder.
As a developer, we are already familiar with the Gateway Service Builder (SEGW) tool, also we know the different ways to create and model an OData service.
Just to list down the different approaches to create and model an OData Service.
- ABAP code-based service Implementation.
- Service Adaptation Description Language (SADL) framework
- Mapping Editor
- Referenced Data Source
- Annotation based approach
SADL framework – A model-driven approach using ABAP CDS Views to create OData service.
Enough of theory, lets jump into the system and see how this is created.
** For the purpose of demonstration, I will use a standard CDS view – A_BillingDocument
Create Gateway Project in Gateway Service Builder (SEGW)
- Project – ZSADL_BILLINGDOCUMENT created.
- To create the Data Model, we need to refer to Data Source. (CDS View in this case).
- In the next screen, we can see all the elements of CDS entity and corresponding Associations.
- Select all the elements and proceed further. (We can select only the fields which are relevant for as per Business Need and we always have the option to edit that later)
- After completing this step all the Entity, Entity Sets, Association & corresponding Navigation is automatically generated in the Gateway Project.
- Now, generate the service.
- After generating Register and Maintain the service. As like any OData service 🙂
Test in Gateway Client (/IWFND/GW_CLIENT)
- Once the service is maintained, it can be tested in the Gateway Client.
- We can see all the Entity and corresponding Association in the Metadata Information.
- We can execute the service with different Entities to see the results.
- The advantage of using the SADL framework with Referenced Data Source is that Mapping (Association & navigation) is derived automatically.
- With this approach change in the OData model is not supported but changes can be done in the SADL model and that reflects in the OData model.
- Also, field extensibility and custom code exits are possible.
So, using this approach OData service implementation can be optimized!
Please feel free to comment and let me know your feedback.
Happy Learning ….Together !! 🙂
Thanks for the Blog Vishal! Intresting one Indeed!!. One question here. Can we add few more additional fields(Custom Fileds) in the Model level of SEGW ? is it possible?
Hi Sri Ram
Yes, you can add custom fields, but you need to add those in the Source (CDS views).
So, create an extension CDS views and you will be able to use custom fields.
Thanks & Regards