Skip to Content

$expand to multiple targets

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 20, 2016 at 12:39 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 13, 2016 at 12:28 AM

    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 ).
    Add comment
    10|10000 characters needed characters exceeded

  • Oct 12, 2017 at 03:51 AM

    Hi All,

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

    Add comment
    10|10000 characters needed characters exceeded