Step by Step Odata Part 3

Embed Size (px)

Citation preview

  • 7/24/2019 Step by Step Odata Part 3

    1/7

    Getting Started Newsletters Store

    Products Services & Support About SCN Downloads

    Industries Training & Education Partnership Developer Center

    Lines of Business University Alliances Events & Webinars Innovation

    LogOn Join UsHi, Guest Search the Community

    Activity Communications Actions

    Browse

    volker.drees

    0

    Thanks for sticking to this multi-part step-by-step 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 e xtended 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 linkinstead 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. Double-clickAssociations:

    2. Choose the Create pushbutton:

    3. Enter the following values for the Association and choose Enter:

    Name SalesOrderSalesOrderItems

    Principal Entity* SalesOrder

    Principal Entity Cardinali ty* 1

    Dependent Entity* SalesOrderItem

    Dependent Entity Cardinali ty* M

    *) This field has an input help

    Now we will Create a referential constraint for the association

    1. Expand theAssociationsnode and the SalesOrderSalesOrderItemsnode and double-click Referential Constraints:

    Step-by-step guide to build an OData Service basedon RFCs Part 3

    Posted by Volker Dreesin volker.dreeson Oct 26, 2012 11:45:07 AM

    ShareShare 0LikeLike

    Register

    Loginto follow, like, comment, share and

    bookmark content.

    Login

    Actions

    By date:

    ---

    By tag:

    gatewaymobilenetweaver_gateway odata rfcsap_netweaver_gatewayservice_builder

    Filter Blog

    Step-by-step guide to build an OData Service based onRFCs Part 3

    Step-by-step guide to build an OData Service based onRFCs Part 2

    Step-by-step guide to build an OData Service based onRFCs Part 1

    How to set up Generic Workflow Handling in Alloy

    How to set up the Verification Workflow in Alloy

    Tiny ABAP Report to fire your Alloy Workflow

    How to enrich your Alloy Workflow with backendattributes

    How to expose a Decision Workflow to Alloy

    How to troubleshoot Duet ESA WebServices - Part 2

    How to troubleshoot Duet ESA WebServices

    Recent Posts

    Incoming Links

    Step-by-Step Add a New Entity with Associationand Implement it

    Displaying only last record(in entityset) multipletimes in Table (Using Association & Navigation)?

    converted by Web2PDFConvert.com

    http://scn.sap.com/people/volker.drees/blog/2009/01/16/how-to-troubleshoot-duet-esa-webserviceshttp://scn.sap.com/people/volker.drees/blog/2009/02/11/how-to-expose-a-decision-workflow-to-alloyhttp://scn.sap.com/message/15783787#15783787http://www.web2pdfconvert.com/?ref=PDFhttps://adclick.g.doubleclick.net/aclk?sa=L&ai=BWUd860U5VvPSM5aL3QHghKegA5CW--MFAAAAEAEgADgAWLDmkL-yAWDJhoCAwKTYD4IBF2NhLXB1Yi04MTUwODY2MDM4MDMyOTQxsgELc2NuLnNhcC5jb226AQlnZnBfaW1hZ2XIAQnaAXhodHRwOi8vc2NuLnNhcC5jb20vcGVvcGxlL3ZvbGtlci5kcmVlcy9ibG9nLzIwMTIvMTAvMjYvc3RlcC1ieS1zdGVwLWd1aWRlLXRvLWJ1aWxkLWFuLW9kYXRhLXNlcnZpY2UtYmFzZWQtb24tcmZjcy1wYXJ0LTPAAgLgAgDqAgtzY25fYmxvZ19hZPgC-dEegAMBkAPoApgD8AGoAwHgBAGQBgGgBhbYBwA&num=0&cid=5GhzLJ6vl60KfovxuFGGJ0sl&sig=AOD64_3NloBKjMyo27izhuGVnuBA2RiWAw&client=ca-pub-8150866038032941&adurl=http://ecohubmkt.sdn.sap.com/Business-Planning-and-Consolidation.html?Referrer=Blogpost-Detail_Fast%20Track_L1_SpaceID:_http://scn.sap.com/people/volker.drees/blog/tags#/?tags=netweaver_gatewayhttp://www.web2pdfconvert.com/?ref=PDFhttp://www.web2pdfconvert.com/?ref=PDFhttp://scn.sap.com/message/15783787#15783787http://scn.sap.com/community/gateway/blog/2015/09/25/step-by-step-add-a-new-entity-with-association-and-implement-ithttp://scn.sap.com/people/volker.drees/blog/2009/01/16/how-to-troubleshoot-duet-esa-webserviceshttp://scn.sap.com/people/volker.drees/blog/2009/02/03/how-to-troubleshoot-duet-esa-webservices--part-2http://scn.sap.com/people/volker.drees/blog/2009/02/11/how-to-expose-a-decision-workflow-to-alloyhttp://scn.sap.com/people/volker.drees/blog/2009/02/26/how-to-enrich-your-alloy-workflow-with-backend-attributeshttp://scn.sap.com/people/volker.drees/blog/2009/02/27/tiny-abap-report-to-fire-your-alloy-workflowhttp://scn.sap.com/people/volker.drees/blog/2009/03/30/how-to-set-up-the-verification-workflow-in-alloyhttp://scn.sap.com/people/volker.drees/blog/2009/09/16/how-to-set-up-generic-workflow-handling-in-alloyhttp://scn.sap.com/people/volker.drees/blog/2012/10/26/step-by-step-guide-to-build-an-odata-service-based-on-rfcs-part-1http://scn.sap.com/people/volker.drees/blog/2012/10/26/step-by-step-guide-to-build-an-odata-service-based-on-rfcs-part-2http://scn.sap.com/people/volker.drees/blog/tags#/?tags=service_builderhttp://scn.sap.com/people/volker.drees/blog/tags#/?tags=sap_netweaver_gatewayhttp://scn.sap.com/people/volker.drees/blog/tags#/?tags=rfchttp://scn.sap.com/people/volker.drees/blog/tags#/?tags=odatahttp://scn.sap.com/people/volker.drees/blog/tags#/?tags=netweaver_gatewayhttp://scn.sap.com/people/volker.drees/blog/tags#/?tags=mobilehttp://scn.sap.com/people/volker.drees/blog/tags#/?tags=gatewayhttps://adclick.g.doubleclick.net/aclk?sa=L&ai=BWUd860U5VvPSM5aL3QHghKegA5CW--MFAAAAEAEgADgAWLDmkL-yAWDJhoCAwKTYD4IBF2NhLXB1Yi04MTUwODY2MDM4MDMyOTQxsgELc2NuLnNhcC5jb226AQlnZnBfaW1hZ2XIAQnaAXhodHRwOi8vc2NuLnNhcC5jb20vcGVvcGxlL3ZvbGtlci5kcmVlcy9ibG9nLzIwMTIvMTAvMjYvc3RlcC1ieS1zdGVwLWd1aWRlLXRvLWJ1aWxkLWFuLW9kYXRhLXNlcnZpY2UtYmFzZWQtb24tcmZjcy1wYXJ0LTPAAgLgAgDqAgtzY25fYmxvZ19hZPgC-dEegAMBkAPoApgD8AGoAwHgBAGQBgGgBhbYBwA&num=0&cid=5GhzLJ6vl60KfovxuFGGJ0sl&sig=AOD64_3NloBKjMyo27izhuGVnuBA2RiWAw&client=ca-pub-8150866038032941&adurl=http://ecohubmkt.sdn.sap.com/Business-Planning-and-Consolidation.html?Referrer=Blogpost-Detail_Fast%20Track_L1_SpaceID:_http://scn.sap.com/login.jspahttp://localhost/var/www/apps/conversion/tmp/scratch_3/login.jspahttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150602/pic59.pnghttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150571/pic58.pnghttp://scn.sap.com/people/volker.drees/blog/2012/10/26/step-by-step-guide-to-build-an-odata-service-based-on-rfcs-part-2http://scn.sap.com/people/volker.drees/blog/2012/10/26/step-by-step-guide-to-build-an-odata-service-based-on-rfcs-part-1http://scn.sap.com/people/volker.drees/bloghttp://localhost/var/www/apps/conversion/tmp/scratch_3/people/volker.dreeshttp://localhost/var/www/apps/conversion/tmp/scratch_3/people/volker.dreeshttp://scn.sap.com/people/volker.drees/blog/2012/10/26/step-by-step-guide-to-build-an-odata-service-based-on-rfcs-part-2http://scn.sap.com/people/volker.drees/bloghttp://localhost/var/www/apps/conversion/tmp/scratch_3/contenthttp://localhost/var/www/apps/conversion/tmp/scratch_3/actionshttp://localhost/var/www/apps/conversion/tmp/scratch_3/communicationshttp://localhost/var/www/apps/conversion/tmp/scratch_3/activityhttp://localhost/var/www/apps/conversion/tmp/scratch_3/community/uachttp://localhost/var/www/apps/conversion/tmp/scratch_3/community/developer-centerhttp://localhost/var/www/apps/conversion/tmp/scratch_3/community/downloadshttp://store.sap.com/http://localhost/var/www/apps/conversion/tmp/scratch_3/community/newslettershttp://localhost/var/www/apps/conversion/tmp/scratch_3/community/getting-startedhttp://scn.sap.com/login.jspahttp://localhost/var/www/apps/conversion/tmp/scratch_3/login.jspahttp://localhost/var/www/apps/conversion/tmp/scratch_3/welcome
  • 7/24/2019 Step by Step Odata Part 3

    2/7

    2. Choose the Createpushbutton:

    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. Double-clickAssociation Sets:

    2. Choose the Create pushbutton:

    3. Enter the values and choose Enter:

    Name SalesOrderSalesOrderItems

    Association* SalesOrderSalesOrderItems

    *) This field has an input help

    Re: expand query option in OData

    Consuming an External RESTful Web Servicewith ABAP in Gateway

    Re: Not able to fetch data using OdataGet_Entityset in SEGW

    Re: Input Parameters for Odata Service

    converted by Web2PDFConvert.com

    http://www.web2pdfconvert.com/?ref=PDFhttp://www.web2pdfconvert.com/?ref=PDFhttp://scn.sap.com/message/14096955#14096955http://scn.sap.com/message/14398644#14398644http://scn.sap.com/community/gateway/blog/2014/03/27/consuming-an-external-restful-web-service-with-abap-in-gatewayhttp://scn.sap.com/message/15539998#15539998http://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150608/pic65.pnghttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150607/pic64.pnghttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150605/pic62.pnghttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150604/pic61.pnghttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150603/pic60.png
  • 7/24/2019 Step by Step Odata Part 3

    3/7

    And finally we create a navigation property based on the referential constraint

    1. Expand Data Model -> Entity Types -> SalesOrderand double-click Navigation Properties:

    2. Choose the Create pushbutton:

    3. Enter the following values and choose Enter:

    Name SalesOrderItemsRelationship Name* SalesOrderSalesOrderItems

    *) This field has an input help

    Now we need to re-generate the runtime objects and were then ready to test the service

    1. Choose the Generatepushbutton:

    2. Verify that the runtime objects have been generated successfully:

    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

    converted by Web2PDFConvert.com

    http://www.web2pdfconvert.com/?ref=PDFhttp://www.web2pdfconvert.com/?ref=PDFhttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150613/pic72.pnghttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150612/pic71.pnghttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150611/pic69.pnghttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150610/pic68.pnghttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150609/pic66.png
  • 7/24/2019 Step by Step Odata Part 3

    4/7

    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/SalesOrderItemsto 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

    converted by Web2PDFConvert.com

    http://www.web2pdfconvert.com/?ref=PDFhttp://www.web2pdfconvert.com/?ref=PDFhttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150620/pic75.pnghttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150619/pic74.pnghttp://scn.sap.com/servlet/JiveServlet/showImage/38-74204-150618/pic73.png
  • 7/24/2019 Step by Step Odata Part 3

    5/7

    Average User Rating

    (16 ratings)

    My Rating:

    0

    .

    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 (re-defining) the GET_EXPANDED_ENTITYmethod.

    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.

    16896 Views

    Products: sap_netweaver_gatewayTopics: mobileTags: gateway, odata, netweaver_gateway, service_builder

    ShareShare 0LikeLike

    11Comments

    Like (0)

    Wouter PeetersOct 6, 2013 1:42 PM

    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 OrderItem entity. Do you have any pointers? Maybe this is a good idea for a part 4.

    Regards,wouter

    Like (1)

    Volker DreesOct 8, 2013 10:32 AM(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 URIthat you use (e.g. ".../SalesOrderItemCollection( SoItemPos=..., SoID=...)/ToProduct" ) onlyhas the key information of the Line Item. In order to be able to navigate to the product entryyou first need to read the Line Item detail to fetch the related Product-Id, and from there fetchthe entire product.Luckily this is taken care of by the Service Builder as well. You just need to make sure tomaintain the Association and the Referential Constraint between the Line Item and theProduct.hth.Regards, Volker

    Like (0)

    Wouter PeetersOct 8, 2013 12:04 PM(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

    Vijay DudlaMay 13, 2014 1:05 PM(in response to Volker Drees)

    converted by Web2PDFConvert.com

    http://www.web2pdfconvert.com/?ref=PDFhttp://www.web2pdfconvert.com/?ref=PDFhttp://localhost/var/www/apps/conversion/tmp/scratch_3/people/vijaybabu.dudlahttp://scn.sap.com/thread/3434085http://localhost/var/www/apps/conversion/tmp/scratch_3/people/wouter.peetershttp://localhost/var/www/apps/conversion/tmp/scratch_3/people/volker.dreeshttp://localhost/var/www/apps/conversion/tmp/scratch_3/people/wouter.peetershttp://scn.sap.com/people/volker.drees/blog/tags#/?tags=service_builderhttp://scn.sap.com/people/volker.drees/blog/tags#/?tags=netweaver_gatewayhttp://scn.sap.com/people/volker.drees/blog/tags#/?tags=odatahttp://scn.sap.com/people/volker.drees/blog/tags#/?tags=gatewayhttp://scn.sap.com/people/volker.drees/blog/tags#/?tags=mobilehttp://scn.sap.com/people/volker.drees/blog/tags#/?tags=sap_netweaver_gateway
  • 7/24/2019 Step by Step Odata Part 3

    6/7

    Hi Volker,I did the same steps but unable to use the navigation or expand option? what wasthe issue.Below is the metadata for my service.-------------ThanksVijay

    converted by Web2PDFConvert.com

    http://www.web2pdfconvert.com/?ref=PDFhttp://www.web2pdfconvert.com/?ref=PDFhttp://www.w3.org/2005/Atomhttp://sapcis01.citrite.net:8080/sap/opu/odata/sap/ZDEMO09_SRV/$metadatahttp://www.w3.org/2005/Atomhttp://sapcis01.citrite.net:8080/sap/opu/odata/sap/ZDEMO09_SRV/$metadatahttp://scn.sap.com/people/volker.drees/blog/2012/10/26//l%20%22%22http://scn.sap.com/people/volker.drees/blog/2012/10/26//l%20%22%22http://scn.sap.com/people/volker.drees/blog/2012/10/26//l%20%22%22http://scn.sap.com/people/volker.drees/blog/2012/10/26//l%20%22%22http://scn.sap.com/people/volker.drees/blog/2012/10/26//l%20%22%22http://scn.sap.com/people/volker.drees/blog/2012/10/26//l%20%22%22http://scn.sap.com/people/volker.drees/blog/2012/10/26//l%20%22%22http://scn.sap.com/people/volker.drees/blog/2012/10/26//l%20%22%22http://scn.sap.com/people/volker.drees/blog/2012/10/26//l%20%22%22http://scn.sap.com/people/volker.drees/blog/2012/10/26//l%20%22%22http://schemas.microsoft.com/ado/2008/09/edmhttp://scn.sap.com/people/volker.drees/blog/2012/10/26//l%20%22%22http://scn.sap.com/people/volker.drees/blog/2012/10/26//l%20%22%22http://www.sap.com/Protocols/SAPDatahttp://schemas.microsoft.com/ado/2007/08/dataservices/metadatahttp://schemas.microsoft.com/ado/2007/06/edmxhttp://scn.sap.com/people/volker.drees/blog/2012/10/26//l%20%22%22
  • 7/24/2019 Step by Step Odata Part 3

    7/7

    Follow SCNSite Index Contact Us SAP Help PortalPrivacy Terms of Use Legal Disclosure Copyright

    Like (0)

    Like (0)

    Shakeeluddin KhajaNov 24, 2014 1:47 PM

    Very useful info . Thanks Volker

    Like (0)

    Starlet AbrahamDec 8, 2014 10:52 AM

    Hi Volker,Your Tutorial has been very helpful. I am learning Webservices from scratch.

    I have a doubt.I cant find the ASSOCIATION SETSblock in my SEGW Project. Would there be a reason for this?ThanksAbraham

    Like (0)

    Volker DreesDec 8, 2014 4:25 PM(in response to Starlet Abraham)

    Hi Abraham,I assume you are using a newer version of SAP NetWeaver Gateway (the blog was writtenfor SP5)?The Gateway Framework is automatically generating the Association Sets based on thedefined Associations. That's the reason why the Service Builder is not showing them in thenavigation tree anymore. But you can still create own Association Sets i f you want (Right-Click on Data Model and choose Create -> Association Set).

    Best Regards, Volker

    Like (0)

    Rahul KeshavMay 25, 2015 10:28 AM

    It worked for me...Thanks Volker......

    Like (0)

    Amber BadamMay 26, 2015 1:55 PM

    very illustrative. nice blog. appreciate it.

    Like (0)

    Kavitha FredrickJul 3, 2015 9:32 AM

    Very Informative..Thanks.

    Like (0)

    Sara ZhangSep 24, 2015 5:26 AM

    Hi Volker,

    It is a wonderful doc, I can not tell you how much I appreciate your work, thanks.

    http://www.web2pdfconvert.com/?ref=PDFhttp://www.web2pdfconvert.com/?ref=PDFhttp://www.sap.com/corporate-en/our-company/legal/copyright/index.epxhttp://www.sap.com/corporate-en/our-company/legal/impressum.epxhttps://accounts.sap.com/ui/public/viewTextResource?scenario=SCN&spId=504efd8ee4b0555c3c17b94e&resourceType=RESOURCE_TERMS_OF_USE&version=1&spDisplayName=SAP%20Community%20Network&locale=enhttps://accounts.sap.com/ui/public/viewTextResource?scenario=SCN&spId=504efd8ee4b0555c3c17b94e&resourceType=RESOURCE_PRIVACYPOLICY&version=1&spDisplayName=SAP%20Community%20Networkhttp://help.sap.com/http://localhost/var/www/apps/conversion/tmp/scratch_3/docs/DOC-18476http://localhost/var/www/apps/conversion/tmp/scratch_3/docs/DOC-19361http://spr.ly/SCNgoogleplushttp://bit.ly/SCNyouThttp://bit.ly/SCNFBhttp://bit.ly/SCNTwRhttp://localhost/var/www/apps/conversion/tmp/scratch_3/people/sara.zhang2http://localhost/var/www/apps/conversion/tmp/scratch_3/people/kavitha.fredrickhttp://localhost/var/www/apps/conversion/tmp/scratch_3/people/amberbadamhttp://localhost/var/www/apps/conversion/tmp/scratch_3/people/rahul.keshav2http://localhost/var/www/apps/conversion/tmp/scratch_3/people/volker.dreeshttp://localhost/var/www/apps/conversion/tmp/scratch_3/people/m4abramshttp://localhost/var/www/apps/conversion/tmp/scratch_3/people/khaja.shakeeluddin