title: Calling expand entity from SAP Gateway Client
body: <p>I try to call a GET_EXPANDED_ENTITYSET method of SRA020_PO_TRACKING Project, po tracking project. The following is the method:</p>
  <pre><code>    METHOD /iwbep/if_mgw_appl_srv_runtime~get_expanded_entityset.
  
    DATA: lv_ponumber TYPE bapiekko-po_number,
          lv_leading_msg TYPE boolean.
  
    DATA: lo_api TYPE REF TO cl_sra020_po_tracking_api.
  
    DATA: ls_po_details TYPE cl_sra020_po_tracking_api=&gt;ts_podetails,
          lt_return TYPE bapirettab,
          lo_msgcontainer TYPE REF TO /iwbep/if_message_container.
  
    DATA: lt_poitem_details TYPE cl_sra020_po_tracking_api=&gt;tt_poitemdetail.
  
    FIELD-SYMBOLS: &lt;fs_return&gt; TYPE bapiret2,
                   &lt;fs_key_tab&gt; TYPE /iwbep/s_mgw_name_value_pair.
  
    lo_api = cl_sra020_po_tracking_api=&gt;get_instance( ).
  
  *========================================================================================
  * Read Entities key values within oData service URL
  *========================================================================================
    IF it_key_tab IS NOT INITIAL.
      LOOP AT it_key_tab ASSIGNING &lt;fs_key_tab&gt;.
  
        CASE &lt;fs_key_tab&gt;-name.
  
          WHEN if_sra020_po_tracking_constant=&gt;cc_po_number.
            lv_ponumber = &lt;fs_key_tab&gt;-value.
  
        ENDCASE.
  
      ENDLOOP.
    ENDIF.
  
  
    TRY.
        CASE iv_entity_set_name.
  
          WHEN if_sra020_po_tracking_constant=&gt;cc_podetaileddatas.
  
            CALL METHOD lo_api-&gt;get_po_details
              EXPORTING
                iv_item_additional_data = 'X'                 &quot;#EC NOTEXT
                iv_po_number            = lv_ponumber
              IMPORTING
                es_po_details           = ls_po_details
                et_return               = lt_return.
  
            IF NOT lt_return IS INITIAL.
              RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception.
            ENDIF.
  
            lt_poitem_details = ls_po_details-poitemdetaildatas.
  
            no_cache( ).
  
  *       Return the expanded clauses
            APPEND cl_sra020_po_tracking_mpc=&gt;gc_poitemdocflow TO et_expanded_tech_clauses.
            APPEND cl_sra020_po_tracking_mpc=&gt;gc_accounting TO et_expanded_tech_clauses.
            APPEND cl_sra020_po_tracking_mpc=&gt;gc_pricingconditions TO et_expanded_tech_clauses.
            APPEND cl_sra020_po_tracking_mpc=&gt;gc_confirmation TO et_expanded_tech_clauses.
  
            CALL METHOD copy_data_to_ref
              EXPORTING
                is_data = lt_poitem_details
              CHANGING
                cr_data = er_entityset.
  
        ENDCASE.
  
      CATCH /iwbep/cx_mgw_busi_exception.
  
        lo_msgcontainer = me-&gt;mo_context-&gt;get_message_container( ).
  
        LOOP AT lt_return ASSIGNING &lt;fs_return&gt; WHERE type EQ 'E' OR type EQ 'A'. &quot;#EC NOTEXT
  
          IF &lt;fs_return&gt;-id EQ 'SRA020'.
            lv_leading_msg = abap_true.
          ELSE.
            lv_leading_msg = abap_false.
          ENDIF.
  
          lo_msgcontainer-&gt;add_message(
                                        iv_msg_type           = &lt;fs_return&gt;-type
                                        iv_msg_id             = &lt;fs_return&gt;-id
                                        iv_msg_number         = &lt;fs_return&gt;-number
                                        iv_msg_text           = &lt;fs_return&gt;-message
                                        iv_msg_v1             = &lt;fs_return&gt;-message_v1
                                        iv_msg_v2             = &lt;fs_return&gt;-message_v2
                                        iv_msg_v3             = &lt;fs_return&gt;-message_v3
                                        iv_msg_v4             = &lt;fs_return&gt;-message_v4
                                        iv_is_leading_message = lv_leading_msg
                                   ).
  
        ENDLOOP.
  
        RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
            EXPORTING
              textid            = /iwbep/cx_mgw_busi_exception=&gt;business_error
              message_container = lo_msgcontainer.
  
    ENDTRY.
  ENDMETHOD.
  </code></pre>
  <p>Where</p>
  <pre><code>if_sra020_po_tracking_constant=&gt;cc_po_number = PONumber 
  if_sra020_po_tracking_constant=&gt;cc_podetaileddatas = PODetailedDatas
  </code></pre>
  <p>and PODetailedData entity has navigation properties of POItemDetailDatas,POItems,and POList</p>
  <p>I try to call the method from Gateway Service Client by executing</p>
  <pre><code>/sap/opu/odata/SAP/SRA020_PO_TRACKING_SRV/PODetailedDatas?$expand=POItemDetailDatas,POItems,POList
  </code></pre>
  <p>However I got status code 400 Bad Request instead. What did I miss?</p>
  <p>regards</p>
  <p>Edit:</p>
  <p>The message in the Bad Request says: <strong>Error while reading Purchase Order</strong></p>
  <p>edit 2:
  association screen shot:</p>
  <img src="https://i.stack.imgur.com/OC5QR.jpg" width="600">
  <p>navigation screen shot:</p>
  <img src="https://i.stack.imgur.com/BmNvK.jpg" width="200">