Created by Wang, Jerry, last modified on Mar 26, 2015
使用SAT运行OData service测试report:
直接运行report:
确保OData service返回正确结果:
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.