on 03-30-2015 1:27 PM
Hello experts,
I am trying to consume oDATA service in ABAP client.
I've created a Project in SAP NWG Service Builder, maintained and activated service in SAP System 1 (SAP NWG).
I want to consume this service in other SAP System 2 (SAP ERP 6.0).
I tried searching different forums and followed the instructions but it didn't work.
Can somebody help me with this?
Thanks,
Ravi
Hi Ravi,
Please see these blogs. These might give you some insights.
http://scn.sap.com/docs/DOC-47366
http://scn.sap.com/docs/DOC-49811
Regards
Prabaharan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravi ,
This code snipped worked me to consume OData service.
REPORT Z_CONSUME_ODATA_SERVICE.
DATA: lo_http_client TYPE REF TO if_http_client,
lv_service TYPE string,
lv_filter TYPE string,
lv_result TYPE string,
lo_ixml TYPE REF TO if_ixml,
lo_streamfactory TYPE REF TO if_ixml_stream_factory,
lo_istream TYPE REF TO if_ixml_istream,
lo_document TYPE REF TO if_ixml_document,
lo_parser TYPE REF TO if_ixml_parser,
lo_weather_element TYPE REF TO if_ixml_element,
lo_weather_nodes TYPE REF TO if_ixml_node_list,
lo_curr_node TYPE REF TO if_ixml_node,
lv_value TYPE string,
lv_node_length TYPE i,
lv_node_index TYPE i,
lv_node_name TYPE string,
lv_node_value TYPE string.
lv_service = 'http://abc.com:8030/sap/opu/odata/sap/TEST_GW/ContactDetails?$filter=IvContact%20eq%20'.
lv_filter = ''''.
CONCATENATE lv_service lv_filter INTO lv_service.
CONCATENATE lv_service '1521458603' INTO lv_service.
lv_filter = ''''.
CONCATENATE lv_service lv_filter INTO lv_service.
cl_http_client=>create_by_url(
EXPORTING
url = lv_service
IMPORTING
client = lo_http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4 ).
CALL METHOD LO_HTTP_CLIENT->AUTHENTICATE(
EXPORTING
CLIENT = '100'
USERNAME = 'abc'
PASSWORD = 'abc'
LANGUAGE = 'E'
)
.
lo_http_client->send(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2 ).
lo_http_client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3 ).
"Prepare XML structure
CLEAR lv_result .
lv_result = lo_http_client->response->get_cdata( ).
WRITE : 'Test Report to cosume OData service'.
More details in this blog .
Also if you Netweaver release is latest one you can make use of this class to achieve the same.
CL_ODL_API
Let me know if this is useful.
Regards
Prabaharan Asokan
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.