cancel
Showing results for 
Search instead for 
Did you mean: 

How to return a deep entityset

perage
Participant
0 Kudos

Hi,

Can anyone provide a suggestion for how to fetch an entityset with tables/collections in it?

I'm fetching material masterdata from backend (S/4 1909) to an offline odata store.

{ material
  material_group
  units [
          { unit_iso
            ean }
          ]

As you can see, I need a table below each entity with additional EAN numbers and their unit. Is the only way to do this to use $expand? The problem, the way I see it, is that I want to fetch all data in one call (one DB call) instead of a lot of expands, as the EAN's should be available for barcode scanning.

Accepted Solutions (1)

Accepted Solutions (1)

AlexGiguere
Contributor

Hi Pete, in SAP gateway you can redefine the method GET_EXPANDED_ENTITYSET and select all your data at once (articles & upcs).

Then you can do a loop inside another loop and prepare the exporting parameter for your entityset

call your URL with a regular expand

https://........../ArticleSet?$expand=UPCs

also use the referential constraints in SAP Gateway when linking your 2 entities

alex

perage
Participant
0 Kudos

Sweet - thanks! Googled a lot about "get deep entityset", but didn't find this simple solution 🙂

perage
Participant
0 Kudos

Hi alexandre.giguere3 !

Regarding referential constraints - is this always recommended? Since my main entity has id(matnr) as key, and list of ean11 and meins are part of each entity, I don’t see the need to add matnr to the units entity and to create constraints. Do you agree or do you see some pros that I don’t?

Answers (0)