
class ZCL_TEST_HTTP definition
public
create public .
public section.
interfaces IF_HTTP_SERVICE_EXTENSION .
protected section.
private section.
ENDCLASS.
CLASS ZCL_TEST_HTTP IMPLEMENTATION.
method IF_HTTP_SERVICE_EXTENSION~HANDLE_REQUEST.
try.
DATA:
lt_business_data TYPE TABLE OF ZZ_BPA_BPRELATIONSHI329148BAE7,
lo_http_client TYPE REF TO if_web_http_client,
* lo_client_proxy TYPE REF TO /iwbep/if_cp_client_proxy,
lo_request TYPE REF TO /iwbep/if_cp_request_read_list,
lo_response TYPE REF TO /iwbep/if_cp_response_read_lst.
DATA(lo_destination) = cl_http_destination_provider=>create_by_cloud_destination(
i_name = 'S4C_DEV_080'
i_authn_mode = if_a4c_cp_service=>user_propagation
).
cl_web_http_client_manager=>create_by_http_destination(
EXPORTING
i_destination = lo_destination
RECEIVING
r_client = lo_http_client
).
**Relative service path**
lo_http_client->get_http_request( )->set_uri_path( '/sap/opu/odata/sap/API_BUSINESS_PARTNER' ).
lo_http_client->set_csrf_token( ).
DATA(lo_client_proxy) = cl_web_odata_client_factory=>create_v2_remote_proxy(
iv_service_definition_name = 'ZZ_TEST0008’
io_http_client = lo_http_client
iv_relative_service_root = '/sap/opu/odata/sap/API_BUSINESS_PARTNER' ).
" Navigate to the resource and create a request for the read operation
lo_request = lo_client_proxy->create_resource_for_entity_set( 'A_BPRELATIONSHIP' )->create_request_for_read( ).
" Create the filter tree
*lo_filter_factory = lo_request->create_filter_factory( ).
*
*lo_filter_node_1 = lo_filter_factory->create_by_range( iv_property_path = 'BUSINESSPARTNER'
* it_range = lt_range_BUSINESSPARTNER ).
*lo_filter_node_2 = lo_filter_factory->create_by_range( iv_property_path = 'BUSINESSPARTNERFISCALYEAR'
* it_range = lt_range_BUSINESSPARTNERFISCALYEAR ).
*lo_filter_node_root = lo_filter_node_1->and( lo_filter_node_2 ).
*lo_request->set_filter( lo_filter_node_root ).
*lo_request->set_top( 50 )->set_skip( 0 ).
" Execute the request and retrieve the business data
lo_response = lo_request->execute( ).
lo_response->get_business_data( IMPORTING et_business_data = lt_business_data ).
CATCH /iwbep/cx_cp_remote INTO data(lx_remote).
" Handle remote Exception
" It contains details about the problems of your http(s) connection
CATCH /iwbep/cx_gateway INTO DATA(lx_gateway).
" Handle Exception
"CATCH cx_web_http_client_error INTO DATA(lx_web_http_client_error).
" Handle Exception
"RAISE SHORTDUMP lx_web_http_client_error.
ENDTRY.
endmethod.
ENDCLASS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
23 | |
19 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 |