Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Interface between SAP & 3rd patry API

former_member187457
Active Contributor
0 Kudos


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:

Rate Quote API

This type of server to server connection enables you to access the ABF API by making a direct call to the ABF server from your server.  The ABF server will return an XML document that you can parse to extract the information you need.
And there a table with the mandatory fields required by ABF.COM

I need to know how to proceed.

Thanks in advance.

RK

1 ACCEPTED SOLUTION

former_member187457
Active Contributor
0 Kudos

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

8 REPLIES 8

SimoneMilesi
Active Contributor
0 Kudos

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!

0 Kudos

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

0 Kudos

Did you read these?

0 Kudos

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.

    endloop.

  endif.

endif.

I hope this will be helpful.

Thanks & Regards,

Raghunadh Kodali.

0 Kudos

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

0 Kudos

Hi Rahul,

Please find the below thread.

http://scn.sap.com/thread/535031

I hope this will be helpful.

Thanks & Regards,

Raghunadh Kodali

former_member187457
Active Contributor
0 Kudos

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

0 Kudos

Hi,

I created webservice using FM.

and gave the WSDL file to the 3rd party team.

It worked.