0
votes

I try to call a GET_EXPANDED_ENTITYSET method of SRA020_PO_TRACKING Project, po tracking project. The following is the method:

    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=>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=>tt_poitemdetail.

  FIELD-SYMBOLS: <fs_return> TYPE bapiret2,
                 <fs_key_tab> TYPE /iwbep/s_mgw_name_value_pair.

  lo_api = cl_sra020_po_tracking_api=>get_instance( ).

*========================================================================================
* Read Entities key values within oData service URL
*========================================================================================
  IF it_key_tab IS NOT INITIAL.
    LOOP AT it_key_tab ASSIGNING <fs_key_tab>.

      CASE <fs_key_tab>-name.

        WHEN if_sra020_po_tracking_constant=>cc_po_number.
          lv_ponumber = <fs_key_tab>-value.

      ENDCASE.

    ENDLOOP.
  ENDIF.


  TRY.
      CASE iv_entity_set_name.

        WHEN if_sra020_po_tracking_constant=>cc_podetaileddatas.

          CALL METHOD lo_api->get_po_details
            EXPORTING
              iv_item_additional_data = 'X'                 "#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=>gc_poitemdocflow TO et_expanded_tech_clauses.
          APPEND cl_sra020_po_tracking_mpc=>gc_accounting TO et_expanded_tech_clauses.
          APPEND cl_sra020_po_tracking_mpc=>gc_pricingconditions TO et_expanded_tech_clauses.
          APPEND cl_sra020_po_tracking_mpc=>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->mo_context->get_message_container( ).

      LOOP AT lt_return ASSIGNING <fs_return> WHERE type EQ 'E' OR type EQ 'A'. "#EC NOTEXT

        IF <fs_return>-id EQ 'SRA020'.
          lv_leading_msg = abap_true.
        ELSE.
          lv_leading_msg = abap_false.
        ENDIF.

        lo_msgcontainer->add_message(
                                      iv_msg_type           = <fs_return>-type
                                      iv_msg_id             = <fs_return>-id
                                      iv_msg_number         = <fs_return>-number
                                      iv_msg_text           = <fs_return>-message
                                      iv_msg_v1             = <fs_return>-message_v1
                                      iv_msg_v2             = <fs_return>-message_v2
                                      iv_msg_v3             = <fs_return>-message_v3
                                      iv_msg_v4             = <fs_return>-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=>business_error
            message_container = lo_msgcontainer.

  ENDTRY.
ENDMETHOD.

Where

if_sra020_po_tracking_constant=>cc_po_number = PONumber 
if_sra020_po_tracking_constant=>cc_podetaileddatas = PODetailedDatas

and PODetailedData entity has navigation properties of POItemDetailDatas,POItems,and POList

I try to call the method from Gateway Service Client by executing

/sap/opu/odata/SAP/SRA020_PO_TRACKING_SRV/PODetailedDatas?$expand=POItemDetailDatas,POItems,POList

However I got status code 400 Bad Request instead. What did I miss?

regards

Edit:

The message in the Bad Request says: Error while reading Purchase Order

edit 2: association screen shot:

navigation screen shot:

1
Does the request without the expand work, i.e. /sap/opu/odata/SAP/SRA020_PO_TRACKING_SRV/PODetailedDatas? Does it enter your method, i.e. indicate you have a programming error, or fail beforehand? Did you model associations from PODetailsDatas to POItemDetailDatas and POItems such that the server knows how to traverse the OData service?Florian
1. PODETAILdATAS_GET_ENTITYSET is not implemented. 2. The method is SAP built in, so it has no error. 3. It is built-in, so Yesethereal1m

1 Answers

1
votes

Turns out I have to provide PONumber, so that:

PODetailedDatas(PONumber='4500000039')?$expand=POItems

works fine