Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 

Working on first gateway project and being asked to expand the parent child entities linked with Navigation Property with a single expansion or RFC call requires quite a bit of self learning. However, when explored the internet, I could not find blogs/links which explained in detail how to use Expansion Method of the Gateway to expand both Parent and Child Entity in a single RFC call, rather than making call first to parent entity and then to the child using $EXPAND parameter in the Odata Service Link.

This scenario is more appropriate for Gateway Hub scenario where in GW(GW_CORE, I_BEP and IW_FND) and ECC are separate systems. An RFC call is made from GW to ECC each time data is requested from UI. Therefore, if the user needs to fetch the Parent Child data using $EXPAND, the gateway framework will first call the entity set for the Parent(SOHeaderSet) and then the entity set for Children(SOItemSet). This results in 2 RFC call to fetch the required data.

In this blog, we will learn how we can reduce 2 RFC calls to a single RFC call and expand both the Parent and Child Entities in a single Odata Service Call.

In order to implement this, we will re define 'GET_EXPANDED_ENTITYSET' Method of the Data Provider Class.

In this example, we will use 2 entities Sales Order Header(SOHeader) and Sales Order Item(SOItem). Both are linked to each other with a navigation property SOHeaderToItem.

Redefine GET_EXPANDED_ENTITYSET as explained in the attached snapshot.

The catch here is that, we have to tell the GW framework that we have expanded both the Header and Item entities in a single entity set call and no need to call the child entity set to fetch the the Sales Order Items. We can do this using parameter ET_EXPANDED_TECH_CLAUSES of GET_EXPANDED_ENTITYSET. Append the Navigation Property Name(SOHEADERTOITEM) in this exporting parameter, which will tell the gate way framework that the child entity has already been expanded and there is no need to call the child entity set.

An important point to not here is that the structure of the output entity set should have a field with Name same as Navigation Property Name(SOHEADERTOITEM). This field has to be a Table Type to support Header and Item relationship structure. Check structure below.

When you will call the Odata Service from the Client with $EXPAND, only the Header Entity Set will be called and no call is made to the Item Entity Set.

https://<Host Server:Port>/sap/opu/odata/sap/ZEXPAND_PARENT_CHILD_SRV/SOHeaderSet?$expand=SOHeaderToItem

In normal expansion scenario with $EXPAND, the gateway framework would first call SOHeaderSet and then the corresponding SOItemSet.

Thanks!!!!

15 Comments