3Step-By-step Guide to Build an OData Service Ba..
January 17, 2017 | Author: Kannan Selvam | Category: N/A
Short Description
Download 3Step-By-step Guide to Build an OData Service Ba.....
Description
16/04/2015
Stepbystep guide to build an OData Service ba... | SCN
Getting Started Newsletters
Hi, Guest
Log On
Join Us
Store
Search the Community
Products
Services & Support
About SCN
Downloads
Industries
Training & Education
Partnership
Developer Center
Activity
Lines of Business
University Alliances
Events & Webinars
Innovation
Browse
Communications
Actions
volker.drees
Stepbystep guide to build an OData Service based on RFCs – Part 3 Posted by Volker Drees in volker.drees on 26Oct2012 11:45:07 Share
0
Tweet
1
Thanks for sticking to this multipart stepbystep guide. Looking into this part (3) means that you have successfully completed the first part (1) and the second part (2) and you are now curious to see how our EPM OData Service will be extended with an Association and a Navigation Property. This will allow us to navigate from the Sales Order to the related Sales Order Line Items by using a link instead of manually putting a filter together. Furthermore this also allows us to use the $expand statement to fetch the Sales Order together with all Sales Order Line Items in one http call. We are still in the Service Builder and enhancing our project that we created in part 1 and extended in part 2. 1. Doubleclick Associations:
2. Choose the Create pushbutton:
3. Enter the following values for the Association and choose Enter: Name SalesOrderSalesOrderItems Principal Entity*
SalesOrder
Principal Entity Cardinality*
1
Dependent Entity*
SalesOrderItem
Dependent Entity Cardinality*
M
*) This field has an input help Now we will Create a referential constraint for the association 1. Expand the Associations node and the SalesOrderSalesOrderItems node and doubleclick Referential Constraints:
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart3
1/7
16/04/2015
Stepbystep guide to build an OData Service ba... | SCN
2. Choose the Create pushbutton:
3. Enter the following values and choose Enter: Principal Key*
SoId
Dependent Property*
SoId
*) This field has an input help
Now we create an association set for the association 1. Doubleclick Association Sets:
2. Choose the Create pushbutton:
3. Enter the values and choose Enter:
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart3
2/7
16/04/2015
Stepbystep guide to build an OData Service ba... | SCN
Name
SalesOrderSalesOrderItems
Association*
SalesOrderSalesOrderItems
*) This field has an input help
And finally we create a navigation property based on the referential constraint 1. Expand Data Model > Entity Types > SalesOrder and doubleclick Navigation Properties:
2. Choose the Create pushbutton:
3. Enter the following values and choose Enter: Name
SalesOrderItems
Relationship Name*
SalesOrderSalesOrderItems
*) This field has an input help Now we need to regenerate the runtime objects and we’re then ready to test the service 1. Choose the Generate pushbutton:
2. Verify that the runtime objects have been generated successfully:
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart3
3/7
16/04/2015
Stepbystep guide to build an OData Service ba... | SCN
3. Start the Gateway Client (Transaction /IWFND/GW_CLIENT) in a separate window to run the service. Provide the following URI to get the metadata for the service: /sap/opu/odata/sap/ZGW100_XX_SO_SRV/$metadata
The Sales Order collection now includes a navigation property. 4. When you now select a sales order entry using /sap/opu/odata/sap/ZGW100_XX_SO_SRV/SalesOrderCollection('0500000001'), for example, you can simply add the navigation link /SalesOrderItems to navigate to the line items without having to set a filter yourself:
5. And finally you can use $expand to read all sales order items for a given sales order in a single http call. Simply provide the following URI: /sap/opu/odata/sap/ZGW100_XX_SO_SRV/SalesOrderCollection('0500000001')/?$expand=SalesOrderItems
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart3
4/7
16/04/2015
Stepbystep guide to build an OData Service ba... | SCN
The $expand statement is handled by the framework (no additional implementation is required). Since the framework does not know that both entities can be obtained using a single RFC call, it executes two calls to the underlying BAPI. This can be improved by manually implementing (redefining) the GET_EXPANDED_ENTITY method. So we are done. The Service is up and running. I hope you enjoyed creating and consuming an OData Service that is based on RFC modules.
11050 Views
Products: sap_netweaver_gateway Topics: mobile Tags: gateway, odata, netweaver_gateway, service_builder
Average User Rating
My Rating:
(6 ratings)
0
Share
Tweet
1
7 Comments Wouter Peeters 06Oct2013 13:42
Hi Volker, Thx, these are a great tutorial series to get started with Gateway. But I'm having some troubles adding a navigation torwards the Product Detail, from the Sales Order Item entity. Do you have any pointers? Maybe this is a good idea for a part 4. Regards, wouter Like (0)
Volker Drees 08Oct2013 10:32 (in response to Wouter Peeters)
Hi Wouter, thanks for the feedback. Navigating from a Line Item to the related Product is a little trickier. This is because the URI that you use (e.g. ".../SalesOrderItemCollection( SoItemPos=..., SoID=...)/ToProduct" ) only has the key information of the Line Item. In order to be able to navigate to the product entry you first need to read the Line Item detail to fetch the related ProductId, and from there fetch the entire product. Luckily this is taken care of by the Service Builder as well. You just need to make sure to maintain the Association and the Referential Constraint between the Line Item and the Product.
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart3
5/7
16/04/2015
Stepbystep guide to build an OData Service ba... | SCN hth. Regards, Volker Like (1)
Wouter Peeters 08Oct2013 12:04 (in response to Volker Drees)
Hi Volker, Thanks for the reply, for more information there's a topic on the matter: http://scn.sap.com/thread/3434085 Regards, Wouter Like (0)
Vijay Dudla 13May2014 13:05 (in response to Volker Drees)
Hi Volker, I did the same steps but unable to use the navigation or expand option? what was the issue. Below is the metadata for my service.
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart3
6/7
16/04/2015
Stepbystep guide to build an OData Service ba... | SCN Thanks Vijay Like (0)
Shakeeluddin Khaja 24Nov2014 13:47
Very useful info . Thanks Volker Like (0)
Starlet Abraham 08Dec2014 10:52
Hi Volker, Your Tutorial has been very helpful. I am learning Webservices from scratch. I have a doubt. I cant find the ASSOCIATION SETS block in my SEGW Project. Would there be a reason for this? Thanks Abraham Like (0)
Volker Drees 08Dec2014 16:25 (in response to Starlet Abraham)
Hi Abraham, I assume you are using a newer version of SAP NetWeaver Gateway (the blog was written for SP5)? The Gateway Framework is automatically generating the Association Sets based on the defined Associations. That's the reason why the Service Builder is not showing them in the navigation tree anymore. But you can still create own Association Sets if you want (Right Click on Data Model and choose Create > Association Set). Best Regards, Volker Like (0)
Site Index Privacy
Contact Us Terms of Use
SAP Help Portal Legal Disclosure
Copyright
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart3
Follow SCN
7/7
View more...
Comments