Showing results for 
Search instead for 
Did you mean: 

How to add $filter in Odata services(version 2.0) for nested array

0 Kudos


I am struggling to add filter for a field that comes inside an array, below is the case structure of OData

   "SalesOrderSellerParty":  {
       PartyID: "1213",
       AddressSnapshotPostalAddress": [
            "ObjectID": "00163E0D6B661EE7BBF815AD0",
            "CountryCode": "SE"
          }       ],

My question is how to add filter for 'CountryCode' because below doesn't work

$filter=SalesOrderSellerParty/AddressSnapshotPostalAddres/CountryCode eq 'SE'

$filter=SalesOrderSellerParty/PartyID eq '1213' works fine though.

This may be very trivial thing but I am unable to find good answer.

Thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos


The OData V2 version has certain rules / restrictions in terms of using filters on nested array :

As I can understand from your OData structure, the navigation property from your header "SalesOrderSellerParty" to your item is "AddressSnapshotPostalAddress". Below are the rules / constraints

  • The nested filter can be used only with Expand clause
  • The nested filter field should be given as Qualified field name
  • The cardinality expected is 1:1

Example : <http url.....>sap/opu/odata/<ServiceName>/SalesOrderSellerPartySet?$expand=AddressSnapshotPostalAddress&$filter=AddressSnapshotPostalAddress/CountryCode eq 'SE'

You can try V4 version of OData which resolves the last constraint of cardinality.

Example : <http url.....>sap/opu/odata/<ServiceName>/SalesOrderSellerPartySet?$expand=AddressSnapshotPostalAddress($filter=CountryCode eq 'SE')