cancel
Showing results for 
Search instead for 
Did you mean: 

$expand and $select together?

Former Member
0 Kudos

Hi guys,

This is likely an obvious one and i'm just being stupid, but for the life of me i can't figure out the syntax to use both $expand and $select at the same time.

I want to use the $select to limit the fields of both the parent and child nodes of the $expand.

In my testing, i either get an error stating the URI is incorrect, or i only get data returned for the parent.

The main URI is:  /sap/opu/odata/sap/zsop_inventory_srv/INVENTORY_SUMMARYSet(Gtin=%275020657110452%27,Site=%271007%27)?sap-client=201&$expand=TO_LOCATION

I want the following fields of INVENTORY_SUMMARYSet:

Article,Gtin,Site,AvailableQty,OpenDelQty,GrTodayQty

I want the following fields of TO_LOCATION:

Article,Gtin,Site,StorageLocation,AvailableQty,OpenDelQty

Many thanks,

Dave

Accepted Solutions (0)

Answers (1)

Answers (1)

nageshcaparthy
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dave,

Please this link:

OData Query Options - SAP NetWeaver Gateway - SAP Library

Also be aware of the Query Constraints: Supported options are listed in [Note 1574568 - SAP NetWeaver Gateway 2.0 - Known Constraints|https://service.sap.com/sap/support/notes/1574568].   There are currently some limitations for query options like $filter.

Regards,

Nagesh

Former Member
0 Kudos

Hi Nagesh,

I'm not entirely sure what you're trying to tell me.

I know how to develop code for gateway services.  In this particular case it's something we were trying not to need with this service.

We're consuming CDS views natively without ABAP.  This seems to work really well, but i can't get $expand and $select to play nicely together and wanted advice on the syntax of the URI or a simple "No, it can't be done right now".

Both $expand and $select show as "No additional implementation needed" in the documentation, meaning it should just work without coding.

I've read the constraints note but cannot see anything explicit which mentions select and expand are not compatible, maybe i'm missing it?

Honestly thank you for the contribution, but I wouldn't have posted here if documentation already existed, as that was the first thing i looked into.

Many thanks,

Dave

Web
Explorer
0 Kudos

Hi Dave,

Use the full path for example:

$select=TO_LOCATION/Article,TO_LOCATION/Gtin,GrTodayQty

I'm sure you can guess the rest...

Cheers,

Dave

JyotiD
Active Participant
0 Kudos

Hi Dave,

Yes it is possible to do $select and $expand together.

I hope you would like to see this from URI Convention Odata V2.0.

URI Conventions (OData Version 2.0) · OData - the Best Way to REST

As mentioned by David URL would look like,

/sap/opu/odata/sap/zsop_inventory_srv/INVENTORY_SUMMARYSet(Gtin='5020657110452',Site='1007')?sap-client=201&$expand=TO_LOCATION&$select=Article,Gtin,TO_LOCATION/Article,TO_LOCATION/Gtin.....

Regards,

Tarun