Skip to Content
0
Former Member
May 06, 2016 at 04:29 PM

Is it possible to get Multi level entities in the Response body using GET_EXPANDED_ENTITYSET?

1090 Views

Hi Everyone,

I have a requirement where I have to get the Response payload in the following way:

<E1>

<RefreshOnDate>2016-04-08</RefreshOnDate>

<E2>

<LabelName>VACATION</LabelName>

<E3>

<Code>B001</Code>

<Group>ABSENCE</Group>

<Description>VACATION</Description>

<OrderOfDisplay>1</OrderOfDisplay>

<IsLeaveIdNeeded>N</IsLeaveIdNeeded>

</TimeCode></TimeLabel><TimeLabel>

</E3>

</E2>

</E1>

As we can see in the above response body, we have 3 levels of hierarchy.

E1 has E2(Table Type) as one of its fields, and E2 has E3(Table Type) as one of its fields.

I have created three separate entities in Gateway builder and have joined then through associations and Navigation.

How in my DPC_EXT method should I pass the Response structure as mentioned above?

Currently, I have used the below structure but the problem is, each entity appears separately in the Response; whereas I want the above mentioned format with nested entities like E1->E2->E3.

DATA : BEGIN OF lw_detl.

INCLUDE TYPE zcl_timecod_mpc=>ts_e1.

DATA : e2 TYPE STANDARD TABLE OF zcl_timecod_mpc=>ts_e2 WITH DEFAULT KEY,

e3 TYPE STANDARD TABLE OF zcl_timecod_mpc=>ts_e3 WITH DEFAULT KEY,


END OF lw_detl.

URI used : /sap/opu/odata/sap/ZTMSRV/E1SET?$filter=RefreshOnDate eq '2016-04-08'&$expand=E2,E3

Please suggest.

Thanks,

Faraz Khan

Attachments

Asso.JPG (25.8 kB)
Nav1.JPG (18.3 kB)
Nav2.JPG (18.1 kB)