‎2008 Oct 27 2:23 PM
Hi All
I do have a requirement to access the data file for loading into SAP. The data file comes through web services. I do not have any idea on what type of web services are available which can throw a data file for uploading and how is that an ABAP program reads this file and gets the data into ABAP internal tables for data uploading? Any inputs on these...?
THanks
Shakir
‎2008 Oct 27 3:29 PM
Hello,
for handling web services, you can refer to this standard help
http://help.sap.com/SAPHELP_NW04S/helpdata/EN/e5/4d350bc11411d4ad310000e83539c3/content.htm
You'll need to use the cl_http_client class for accessing your web service.
here is some pseudo code.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_ws_request
IMPORTING
client = http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.
CALL METHOD http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.
<------- here I get the http_communication_failure
CALL METHOD http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
CLEAR lv_ws_response .
lv_ws_response = http_client->response->get_cdata( ).
free http_client.
--> now you have your XML data in the string lv_ws_response coming from your webservice.
From here you can then transform it into an ABAP format using transformations
hope it helps
Koen Van Loocke
‎2008 Oct 27 3:29 PM
Hello,
for handling web services, you can refer to this standard help
http://help.sap.com/SAPHELP_NW04S/helpdata/EN/e5/4d350bc11411d4ad310000e83539c3/content.htm
You'll need to use the cl_http_client class for accessing your web service.
here is some pseudo code.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_ws_request
IMPORTING
client = http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.
CALL METHOD http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.
<------- here I get the http_communication_failure
CALL METHOD http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
CLEAR lv_ws_response .
lv_ws_response = http_client->response->get_cdata( ).
free http_client.
--> now you have your XML data in the string lv_ws_response coming from your webservice.
From here you can then transform it into an ABAP format using transformations
hope it helps
Koen Van Loocke
‎2008 Oct 27 3:42 PM
Hi Koen Van
After going through your reply, I guess this program requires only the URL.
Correct this, 'The classes/methods will read into the URL and get the XML data into the internal tables. These internal tables will be processed and the data loaded'. Is my thinking correct.
Can you explain the exporting and importing parameters that 'Create_by_url' method takes. It will be really great if you can give me a code snippet on how I get the XML data from a web service.
Shakir.
‎2008 Oct 27 3:31 PM
if the file is in app server you will use OPEN DATASET..
if the file is put in presentation server you might use ws_upload or gui_upload to read data in to internal tables.
you have a class also which does the same work..CL_GUI_FRONTEND_SERVICES