从 SAP Gateway Client 调用扩展实体

Calling expand entity from SAP Gateway Client

我尝试调用SRA020_PO_TRACKING项目的GET_EXPANDED_ENTITYSET方法,po跟踪项目。以下是方法:

    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.

在哪里

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

PODetailedData 实体具有 POItemDetailDatas、POItems 和 POList 的导航属性

我尝试通过执行

从网关服务客户端调用方法
/sap/opu/odata/SAP/SRA020_PO_TRACKING_SRV/PODetailedDatas?$expand=POItemDetailDatas,POItems,POList

但是我得到的是状态代码 400 Bad Request。我错过了什么?

问候

编辑:

错误请求中的消息显示:读取采购订单时出错

编辑 2: 关联屏幕截图:

导航截图:

原来我必须提供 PONumber,所以:

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

工作正常