cancel
Showing results for 
Search instead for 
Did you mean: 

$expand to multiple targets

TimMuchena
Participant
0 Kudos

Hello people

I have a scenario where I have one primary entity say SalesOrder and 2 secondary entities(Items and Products). I want to expand from SalesOrder to Items and also from SalesOrder to Products. How do I implement multiple expand in the GET_EXPANDED_ENTITY AND GET_EXPANDED_ENTITYSET

Thank you

Accepted Solutions (1)

Accepted Solutions (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Timothy,

Please have a look at the below : This will give you idea on how to model the serivce as per your requireents.

https://blogs.sap.com/2014/07/18/implementing-expand-entityentity-set/

Regards,

Ashwin

Answers (2)

Answers (2)

former_member185414
Active Contributor
0 Kudos

Hi All,

Though late but I implemented something similar here - https://blogs.sap.com/2017/09/18/generic-expanded-entity-implementation/

UxKjaer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Timothy,

When you have your entity in the method, you can add the expanded other entities to it. Just declare your entityset with the "child" entities and return this.

In my example below i have done it for purchase order, which is used to recieve GR items and also purchase order items.

    DATA:  BEGIN OF ls_expanded_order.

   INCLUDE       TYPE ZCL_ZGW_PO_GR_MPC=>TS_ET_PURCHASEORDERHEADER.

   DATA: ET_GRITEM     TYPE ZCL_ZGW_PO_GR_MPC=>TT_ET_PURCHASEORDERITEM,

         ET_PurchaseOrderItemSet    TYPE ZCL_ZGW_PO_GR_MPC=>TT_ET_PURCHASEORDERITEM,

        END OF ls_expanded_order.

...


   copy_data_to_ref(

         EXPORTING

           is_data = lt_order_item

         CHANGING

           cr_data = er_entityset ).