This programming information includes code snippets to illustrate the ABAP SMI OData API.
DATA: lo_api TYPE REF TO if_odl_api, lo_request TYPE REF TO if_odl_request, lv_result_code TYPE clb2_result_code, lo_entity TYPE REF TO if_odl_entity, lo_propcomplex TYPE REF TO if_odl_propcomplex, lv_prop_value TYPE string, lx_process TYPE REF TO cx_odl_process. * get an API object lo_api ?= cl_odl_api=>s_create( iv_application_id = 'ODATA_TEST' iv_platformtype = 'ODataTestV2' "points to http://services.odata.org/V2/ (check transactions CLB2_APPLI_PLATF and CLB2_PLATF) iv_service = 'DEFAULT' ). "points to OData/OData.svc (in transaction SM31, check view CLB2V_SERVICE_C) *------------------------------------------------------------------------- * build the request * GET Suppliers(1) * URL: http://services.odata.org/V2/OData/OData.svc/Suppliers(ID=1) lo_request = lo_api->get_request( 'Suppliers' ). lo_request->navigate_by_simple_key( iv_name = 'ID' iv_value = '1' ). TRY. * submit the request lo_request->submit( ). * collect the result lv_result_code = lo_request->get_result_code( ). lo_entity = lo_request->get_result_entity( ). lo_propcomplex = lo_entity->get_complex_property( 'Address' ). lv_prop_value = lo_propcomplex->get_simple_property_value( 'City' ). CATCH cx_odl_process INTO lx_process. ENDTRY.