How to modify SAP ABAP OData model to support $expand operation trial version

As mentioned in the introductory article SAP OData Development Tutorial - From Getting Started to Improving (including SEGW, RAP and CDP) , SAP OData service development, technically speaking, can be divided into three categories. Therefore, this tutorial is also divided into three parts, which will be introduced separately. This article is the article directory for this tutorial.

About the Author

Jerry Wang, joined the SAP Chengdu Research Institute after graduating from the University of Electronic Science and Technology of China with a master's degree in computer science in 2007. Jerry is a SAP Community Mentor and a SAP China Technology Ambassador. In his 15-year career in SAP standard product development, Jerry has participated in the research and development of standard products such as SAP Business ByDesign, SAP CRM, SAP Cloud for Customer, SAP S/4HANA, and SAP Commerce Cloud (e-commerce cloud).

Jerry has in-depth research on the development, testing, publishing, deployment, testing of SAP OData services, as well as the behind-the-scenes technical implementation details and usage scenarios of OData services based on various SAP technologies.

Development tutorial based on SEGW - Gateway Service Builder

Develop OData services using the Restful ABAP Programming model (RAP for short)

  • Currently writing, stay tuned

Develop OData services using the SAP Cloud Application Programming programming model

  • Currently writing, stay tuned

Application scenarios of $expand operation in OData service

The OData model creation we have completed so far in this step has only one node, Book. In the actual project, the OData model is much more complicated than the model designed for teaching purposes in our tutorial.

For example, the following figure is the OData model of the SAP CRM My Opportunities Fiori application. You can see that the model root node Opportunity can navigate to other child nodes. For example, as we will learn in this step Navigation Properties(导航属性), starting from the root node Opportunity, you can navigate to other child nodes. node. For example, the yellow Products in the figure below is one of the navigation properties. Through this field, you can navigate to all the Products data contained in the Opportunity.

This navigational affiliation between Opportunity and Products is also reflected in the UI of the Fiori application. My Opportunity is a Fiori application. The detail page of Opportunity has several Tab pages. Starting from the second tab page, each tab page corresponds to a child node of the Opportunity OData model. Take the Products tab in the following figure as an example, the data it contains is technically obtained by navigating to the OData model sub-node Products through the Opportunity root node and using the Navigation Property of Products.

We open the Chrome Developer Tools network tab and find an HTTP request url:

GET Opportunities(guid'FA163EE5-6C3A-1ED6-9DC1-C10749724C39')?$expand=Competitors,Products,OpportunityLogSet HTTP/1.1

In this url, not only the data of FA163EE5-6C3A-1ED6-9DC1-C10749724C39the , but also the data of its child nodes , such as , is retrieved through the $expandoperation defined by the OData protocol.在同一个 HTTP 请求里CompetitorsProducts

It can be seen that the function of the OData protocol $expandis to retrieve the root node and the child node data specified by the Navigation Property in the same HTTP request, thereby reducing the HTTP request for the same purpose of data reading. number.

Below are specific steps on how our own OData service supports $expandoperations .

Guess you like

Origin blog.csdn.net/i042416/article/details/126402800