Skip to Content
Author's profile photo Rashmi BR

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)

          /wp-content/uploads/2013/11/compose_service2_284383.jpg

  • Select the Service in External System option. This makes the RFC Destination text field editable.

/wp-content/uploads/2013/11/include1_284399.jpg

  • 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.

/wp-content/uploads/2013/11/compose_service3_284574.jpg

  • Once an external service is included, a Model Reference entry gets added into the Data Model with Model Reference Type: Include

    /wp-content/uploads/2013/11/include_serv1_284424.jpg

  • 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!

     /wp-content/uploads/2013/11/ext_assoc1_284425.jpg

          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.

         EXT_ASS2.png

  • 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.

       EXT_ASS2.jpg

  • 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

      /wp-content/uploads/2013/11/serv_doc_284451.jpg

          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

Assigned Tags

      21 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Tammy Powlas
      Tammy Powlas

      This is nice - why not post it in the SAP Gateway  so the community can have better visibility to your work?

      Author's profile photo Rashmi BR
      Rashmi BR
      Blog Post Author

      Done Tammy Powlas! Thanks a lot for the quick feedback 🙂

      Author's profile photo Krishna Kishor Kammaje
      Krishna Kishor Kammaje

      Good one Rashmi. 🙂 Will wait for the Runtime.

      When you say External System do you mean services like Nortwind?

      Author's profile photo Rashmi BR
      Rashmi BR
      Blog Post Author

      Thanks a lot Krishna 🙂

      It could be any service registered on a Gateway system which you could connect to via an RFC destination.

      Author's profile photo Sreenivas Pachva
      Sreenivas Pachva

      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...

      Author's profile photo Rashmi BR
      Rashmi BR
      Blog Post Author

      Thanks a lot Sreenivas . I am overwhelmed 🙂

      Author's profile photo Syambabu Allu
      Syambabu Allu

      Good Stuff.

      Thanks,

      Syam

      Author's profile photo Rashmi BR
      Rashmi BR
      Blog Post Author

      Thanks Syam

      Author's profile photo Carlos Roggan
      Carlos Roggan

      Thanks for this useful and helpful and interesting and nicetoread Blog, Rashmi!

      Cheers, Carlos

      Author's profile photo Rashmi BR
      Rashmi BR
      Blog Post Author

      Thanks a lot Carlos 🙂

      Author's profile photo Arun Chembra
      Arun Chembra

      Thanks for sharing .......... nice document

      Author's profile photo Rashmi BR
      Rashmi BR
      Blog Post Author

      Thanks Arun 🙂

      Author's profile photo Former Member
      Former Member

      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?

      Author's profile photo Former Member
      Former Member

      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.

      Author's profile photo Mario Aerts
      Mario Aerts

      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?

      Author's profile photo Hemendra Sabharwal
      Hemendra Sabharwal

      Thanks Rashmi, Good document.

      Warm Regards

      Hemendsra

      Author's profile photo Former Member
      Former Member

      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?

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Former Member
      Former Member

      Hi Marc,

       

      I am getting the same error. Is this fixed?

      Please propose a solution.

       

      Thanks,

      Kavitha

      Author's profile photo Sai Sankara Rao Battula
      Sai Sankara Rao Battula

      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.

      Author's profile photo Ramesh Arsam
      Ramesh Arsam

      How to access these two entities using expand keyword  ?