Design Time: How to Compose Multiple OData Services using SAP Gateway
As I could not find any writing on Composition feature of Gateway(available since SP05) where two/multiple services can be composed into one, here it goes…
Consider a scenario where you have two independent OData services(say, Sales Order and Business Partner). The two can be connected (associated) to see Business Partner details of a Sales Order. This can be achieved using the functionality Include->OData Service(GW) available in SEGW Data Model of SAP NetWeaver Gateway (SP05 and above).
Here you would have option either to
1) Compose current service(in a project) with one or multiple services in a) Current System OR b) External System.
OR
2) Compose 2 independently existing services(in Current/External systems) into a new service(project)
Lets consider the case 1) variance b) where we compose current service(in a project) with one service in External system.
Through this writeup I will also mention the difference in behaviour with the Current System case.
Assumption is that Sales Orders and Business Orders OData services are generated and registered out of service builder(SEGW) in two different systems.
- Open the corresponding Sales Orders project and go to edit mode using the pencil toolbar button.
- On the Data Model right click and invoke Include->OData Service(GW)
- Select the Service in External System option. This makes the RFC Destination text field editable.
- Using the F4 provided, chose the required RFC destination of the system where Business Orders service resides.
Use the F4 help to select the Technical Service Name and Version and chose to continue using the tick.
- Once an external service is included, a Model Reference entry gets added into the Data Model with Model Reference Type: Include
- Next step is to associate the two models. Go to Associations Folder in the Data Model, add an entry. Give it a name.
- Now create an External Association called so as this is between two entities of 2 different services.
Click on the Ext Assoc button to invoke the Creation of External Association.
- Choose the option External from the drop down of Association Type.
Once External is chosen, since the project now has only one included model, the dependent Model Reference gets proposed since there is only one service is included in the project, else this has to be filled using F4 help.
The proposal given can be over ridden anyways!
In case where 2 or more services(from Current/External systems) are included, and your design requires you to associate entities of the included services, the Dependent and Principal model references can be chosen via F4 helps provided.
The RFC destination for Metadata field becomes available when we have included Service in Current System. This is a special case where the Metadata exists in an external system and the service is generated in the current system. A typical example for this would be an integration case where SPI’s ABBID exists in another system and the OData service is generated in the current system. For more information on SPI integration please refer the blog SPI Integration with GW by Ashish Kumar and Harish
- Next step is to continue using the tick available. As a result, it shows the Ext Assoc button enabled with a tick indicating External Association is created.
- Now, use the F4 of Prinicipal Entity to chose the Sales Order entity.
The F4 provided on the Dependent Entity doesn’t fetch entities of the service as the Model included is via Service in External System. This is because of a technical limitation. This means to say, one has to know the entity name of the service and enter it manually.
Where as in case of Model included via Service in Current System this F4 would list the entities, and you can select the required entity.
- Enter the Dependent Entity name manually.
- Go ahead and fill in the cardinalities as well like shown in the screenshot above.
Now a composed project is ready for generation of an OData service.
- Use Generate Runtime Objects button in the toolbar to generate artifacts like the service, model and classes.
- Register using the Service Maintenance feature.
- Click on Maintain toolbar button which leads to GW client OR T Code: /IWFND/GW_CLIENT to check the service doc.
It looks like in the screenshot below
This brings to a closure of phase 1, where the service document has collections/entitysets of both services composed into ONE 🙂
Thanks for going through the blog and any feedback would be most welcome !
Would be linking this to another blog on the Run Time soon… so, please stay tuned…
Thanks,
Rashmi
This is nice - why not post it in the SAP Gateway so the community can have better visibility to your work?
Done Tammy Powlas! Thanks a lot for the quick feedback 🙂
Good one Rashmi. 🙂 Will wait for the Runtime.
When you say External System do you mean services like Nortwind?
Thanks a lot Krishna 🙂
It could be any service registered on a Gateway system which you could connect to via an RFC destination.
Hi Rashmi,
Excellent useful information..Thanks for the sharing new things in Gateway..like image upload and composition and I hope that you keep continue your views with SCN contributers...
🙂 And also I am big fan of your blogs ...Your blogs can make the complex things into so simple...
Thanks a lot Sreenivas . I am overwhelmed 🙂
Good Stuff.
Thanks,
Syam
Thanks Syam
Thanks for this useful and helpful and interesting and nicetoread Blog, Rashmi!
Cheers, Carlos
Thanks a lot Carlos 🙂
Thanks for sharing .......... nice document
Thanks Arun 🙂
Hi Rashmi
Thank you for the useful blog.
I have a question. I tried linking up services from ECC and BI into one service. Where do I register this service in a hub architecture? using SPI?
Hi Rashmi,
This is very helpful blog.
I am new to gateway, could you please update the further part on how to run this service to get result for both of services.
Hi Rashmi,
i am implementing an included OData service and have a problem that in my implementation of my included OData servce I do not receive the keys from the principal entity. See Implementing an included odata service
Do you have a solution?
Thanks Rashmi, Good document.
Warm Regards
Hemendsra
Hi Rashmi,
I am using same concept, I am creating association between one entity in current service and one entity from included service. When I use $expand, i get error as Entity from included set is not found. Can you suggest solution?
Hi Rashmi,
Good post by the way. When I try to consume the service, I get an error : Entity by ID ' ' not found.
Any idea of what the problem could be ?
Thank you
Hi Marc,
I am getting the same error. Is this fixed?
Please propose a solution.
Thanks,
Kavitha
Hi Rashmi/Others
Asking this question after many years :).
When you say below assumption:
Assumption is that Sales Orders and Business Orders OData services are generated and registered out of service builder(SEGW) in two different systems.
is it Hub model? GW+ECC, is it possible to use include between GW and backend? or it is possible b/w 2 GW systems?
Thanks,
Sai Battula.
How to access these two entities using expand keyword ?