Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Using $expand with multi-level relationships

Hello all,

I have a gateway service where I have defined entity types and their relationships in the service builder as follows:

Root -> NodeA -> NodeB

Root -> NodeC -> NodeD

Root -> NodeE -> NodeF

I have defined all relationships as 1-N. I have implemented GET_ENTITY_SET and GET_ENTITY methods for all entity types and when I run them individually they are returning the data I expect.

I have been studying using $expand for deep reads so that I can return the content of all entity types with one call. Ideally, as this data set is relatively small, I would like to perform a single GET like this:

/sap/opu/odata/sap/ZMYTEST_SRV/RootSet?$expand=NodeA/NodeB,NodeC/NodeD,NodeE/NodeF

When I test the $expand command returning all the second level entity sets like this:

/sap/opu/odata/sap/ZMYTEST_SRV/RootSet?$expand=NodeA,NodeC,NodeE

it works as expected.

Also, when I test the $expand command returning the lower level entity set from the second level entity set like this:

/sap/opu/odata/sap/ZMYTEST_SRV/NodeASet/?$expand=NodeB

it works as expected.

However, as soon as I attempt to return the lower level entity sets from the top level using a command like this:

/sap/opu/odata/sap/ZMYTEST_SRV/RootSet?$expand=NodeA/NodeB

I get a 500 connection timeout on the server.

I have not implemented GET_EXPANDED_ENTITYSET or GET_EXPANDED_ENTITY. Do you expect that not implementing these is causing my current timeout issues? Should these methods always be implemented for performance gains? Does anyone know of any good examples of implementing these methods to achieve what I'm trying to do?

Many thanks in advance.

Steve

Tags:
Former Member
Former Member replied

Hi Steve,

You don't have to implement the Get_Expand* methods for expand to work,

as the Gateway FW  offers a generic $expand functionality.

Although then you do some performance compromizing.

Check that all your navigations works without $expand , it might be a wrong navigation property that you used.

And finally if you still don't find the problem, debug it , 500 is usually an issue with the specific service code.

BR

Roy

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question