天天看點

使用ABAP SAT工具分析SAP OData service實作明細Created by Wang, Jerry, last modified on Mar 26, 2015

Created by Wang, Jerry, last modified on Mar 26, 2015

使用SAT運作OData service測試report:

使用ABAP SAT工具分析SAP OData service實作明細Created by Wang, Jerry, last modified on Mar 26, 2015

直接運作report:

使用ABAP SAT工具分析SAP OData service實作明細Created by Wang, Jerry, last modified on Mar 26, 2015

確定OData service傳回正确結果:

使用ABAP SAT工具分析SAP OData service實作明細Created by Wang, Jerry, last modified on Mar 26, 2015
REPORT ZGATEWAY_TOOL.
PARAMETERS: url TYPE string OBLIGATORY DEFAULT `/sap/opu/odata/SAP/CRM_OPPORTUNITY/Opportunities(guid'0090FA11-45EC-1ED2-B7C9-DDF68EF91193')?$expand=Products`.
 DATA:lo_http_client           TYPE REF TO if_http_client,
         lv_status                TYPE i,
         lt_header                TYPE TIHTTPNVP,
         ls_header                LIKE LINE OF lt_header,
         lv_sysubrc               TYPE sysubrc.
    CALL METHOD cl_http_client=>create_by_destination
      EXPORTING
        destination                = 'NONE'
      IMPORTING
        client             = lo_http_client
      EXCEPTIONS
        argument_not_found = 1
        plugin_not_active  = 2
        internal_error     = 3
        OTHERS             = 4.
    ASSERT sy-subrc = 0.
    CALL METHOD lo_http_client->request->set_method( if_http_request=>co_request_method_get ).
*Disable pop-up when request receives unauthorized error: error 401.
    lo_http_client->propertytype_logon_popup = if_http_client=>co_disabled.
*Send request.
ls_header-name = '~request_method'.
ls_header-value = 'GET'.
APPEND ls_header TO lt_header.
ls_header-name = '~request_uri'.
ls_header-value = url.
APPEND ls_header TO lt_header.
lo_http_client->request->set_header_fields( lt_header ).
    CALL METHOD lo_http_client->send
      EXCEPTIONS
        http_communication_failure = 1
        http_invalid_state         = 2
        http_processing_failed     = 3.
    ASSERT sy-subrc = 0.
* Get response.
    CALL METHOD lo_http_client->receive
      EXCEPTIONS
        http_communication_failure = 1
        http_invalid_state         = 2
        http_processing_failed     = 3.
   IF sy-subrc <> 0.
        CALL METHOD lo_http_client->get_last_error
        IMPORTING
          code    = lv_sysubrc
          message = DATA(ev_message).
        BREAK-POINT.
        RETURN.
   ENDIF.
   DATA(lv_text) = lo_http_client->response->get_cdata( ).
   lo_http_client->close( ).
   BREAK-POINT.      

繼續閱讀