10-22-2014 12:13 PM
Hi All,
I have a requirment to intract with 3rd party API from SAP R3.
3rd party is a shipper..... ABF.COM
We are looking for rate Quote data from ABF.COM while creating Delivery.
ABF.COM has provided following details:
I need to know how to proceed.
Thanks in advance.
RK
10-27-2014 9:42 AM
Hi ,
Do i need PI as middleware?
In my case i need to pass data in URL as below:
https://www.abcdf.com/xml/aquotexml.asp?DL=2&ID=HRJRGLZ2&ShipCity=Dallas&ShipState=TX
&ShipZip=75201&ShipCountry=US&ConsCity=Tulsa&ConsState=OK
&ConsZip=74104&ConsCountry=US&Wgt1=600&Class1=100.0&ShipAff=Y
&ShipMonth=10&ShipDay=30&ShipYear=2014
and in response we get data in .XML file.
Please suggest the steps.
Thnx
RK
10-22-2014 12:36 PM
Greeting Rahul!
i maintained a report for a similar request (getting an xml file from webserver with all the currency exchange rate).
i share here the code i implemented
DATA: host TYPE string,
service TYPE string,
path TYPE string,
errortext TYPE string,
uri TYPE string,
timeout TYPE i,
subrc TYPE sysubrc,
proxy_host TYPE string,
proxy_service TYPE string.
DATA: pdf_html_control TYPE REF TO cl_gui_html_viewer,
pdf_my_container TYPE REF TO cl_gui_custom_container,
pdf_alignment TYPE i.
DATA: rlength TYPE i,
txlen TYPE string .
DATA: wf_string TYPE string,
wx_abap TYPE xstring,
wf_string1 TYPE string.
DATA: capo(5).
DATA: soapurl TYPE string,
str_guid TYPE string,
str_docty TYPE string,
str_doc TYPE string,
l_err.
cLEAR: rlength,
txlen.
CONCATENATE
'<?xml version="1.0" encoding="utf-8"?>'
'<soap12:Envelope xmlns:xsi="http://www.w3.'
'org/2001/XMLSchema-instance"'
' xmlns:xsd="http://www.w3.org/2001/'
'XMLSchema" xmlns:soap12="http://'
'www.w3.org/2003/05/soap-envelope">'
' <soap12:Body>'
<<<<<HERE the method/class you are invoking>>>>>
' </soap12:Body>'
'</soap12:Envelope>'
INTO wf_string .
rlength = strlen( wf_string ).
MOVE rlength TO txlen.
soapurl = <<<YOUR URL>>>>
CONDENSE soapurl.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = soapurl
IMPORTING
client = client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
EXIT.
ENDIF.
*
************************************************************************
*
CALL METHOD client->request->set_header_field
EXPORTING
name = '~request_method'
value = 'POST'.
CALL METHOD client->request->set_header_field
EXPORTING
name = '~server_protocol'
value = 'HTTP/1.1'.
CALL METHOD client->request->set_header_field
EXPORTING
name = 'Content-Type'
value = 'text/xml'.
CALL METHOD client->request->set_header_field
EXPORTING
name = 'Content-Length'
value = txlen.
CALL METHOD client->request->set_cdata
EXPORTING
data = wf_string
offset = 0
length = rlength.
CALL METHOD client->send
EXPORTING
timeout = timeout
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
CALL METHOD client->get_last_error
IMPORTING
code = subrc
message = errortext.
PERFORM send_mail_error.
EXIT.
ENDIF.
CALL METHOD client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
CALL METHOD client->get_last_error
IMPORTING
code = subrc
message = errortext.
PERFORM send_mail_error.
EXIT.
ENDIF.
CLEAR: wf_string1,
wx_abap.
wf_string1 = client->response->get_cdata( ).
wx_abap = client->response->get_data( ).
CALL METHOD client->close
EXCEPTIONS
http_invalid_state = 1
OTHERS = 2.
Your WF_STRING1 contains the xml document you can manage via trasformation
Hope this could be useful for you!
10-24-2014 4:29 PM
Hi SM,
I am getting error at http_client->receive ..error is HTTPIO_PLG_CANCELED.
Pleas let me if any other settings required.
Thanks,
RK
10-24-2014 4:39 PM
10-24-2014 5:04 PM
Hi Rahul,
Please test the below code by changing your URL.
DATA: SMS_TEXT TYPE STRING,
SMS_TEXT_UTF TYPE STRING,
SEND_STRING TYPE STRING.
DATA: w_string TYPE string ,
w_result TYPE string ,
r_str TYPE string .
DATA: result_tab TYPE TABLE OF string.
DATA: http_client TYPE REF TO if_http_client.
SEND_STRING = 'http://www.currencyserver.de/webservice/currencyserverwebservice.asmx/getDollarValue?provider=AVERAG...'.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = SEND_STRING
IMPORTING
client = http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
others = 4.
if sy-subrc = 0.
CALL METHOD http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.
CALL METHOD http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
if sy-subrc = 0.
w_result = http_client->response->get_cdata( ).
REFRESH result_tab .
SPLIT w_result AT cl_abap_char_utilities=>cr_lf INTO TABLE result_tab .
loop at result_tab into w_result.
write 😕 w_result.
endif.
endif.
I hope this will be helpful.
Thanks & Regards,
Raghunadh Kodali.
10-24-2014 5:30 PM
Hi Raghu,
I tried your code ....m still getting error at CALL METHOD http_client->receive ....subrc = 1...ie. http_communication_failure.
looks like some config missing.
Please let me know wt m missing.
THnx
RK
10-24-2014 5:59 PM
Hi Rahul,
Please find the below thread.
http://scn.sap.com/thread/535031
I hope this will be helpful.
Thanks & Regards,
Raghunadh Kodali
10-27-2014 9:42 AM
Hi ,
Do i need PI as middleware?
In my case i need to pass data in URL as below:
https://www.abcdf.com/xml/aquotexml.asp?DL=2&ID=HRJRGLZ2&ShipCity=Dallas&ShipState=TX
&ShipZip=75201&ShipCountry=US&ConsCity=Tulsa&ConsState=OK
&ConsZip=74104&ConsCountry=US&Wgt1=600&Class1=100.0&ShipAff=Y
&ShipMonth=10&ShipDay=30&ShipYear=2014
and in response we get data in .XML file.
Please suggest the steps.
Thnx
RK
04-21-2015 10:39 AM
Hi,
I created webservice using FM.
and gave the WSDL file to the 3rd party team.
It worked.