on ‎2023 Feb 14 7:00 PM
Hi ,
I have a requirement that i have data in excel file in some other location and this data i have to read in abap program using REST API.
Below code has used to read data but unable to process it.
<br>
lv_url = 'https://xxxxxxxxxxx'')/$value'.<br><br>CLEAR lo_http_client.<br>CALL METHOD cl_http_client=>create_by_url<br> EXPORTING<br> url = lv_url<br> IMPORTING<br> client = lo_http_client<br> EXCEPTIONS<br> argument_not_found = 1<br> plugin_not_active = 2<br> internal_error = 3<br> pse_not_found = 4<br> pse_not_distrib = 5<br> pse_errors = 6<br> oa2c_set_token_error = 7<br> oa2c_missing_authorization = 8<br> oa2c_invalid_config = 9<br> oa2c_invalid_parameters = 10<br> oa2c_invalid_scope = 11<br> oa2c_invalid_grant = 12<br> OTHERS = 13.<br>IF sy-subrc <> 0.<br>ENDIF.<br><br>lo_http_client->propertytype_logon_popup = lo_http_client->co_disabled.<br><br>CALL METHOD lo_http_client->request->set_method<br> EXPORTING<br> method = 'GET'.<br><br>CALL METHOD lo_http_client->request->set_header_field<br> EXPORTING<br> name = 'Content-Type'<br> value = 'application/json; odata=verbose'.<br><br>CALL METHOD lo_http_client->request->set_header_field<br> EXPORTING<br> name = 'Accept'<br> value = 'application/json; odata=verbose'.<br><br>CALL METHOD lo_http_client->request->set_header_field<br> EXPORTING<br> name = 'Authorization'<br> value = lv_auth.<br>
lo_http_client->send( ).<br><br><br>lo_http_client->receive(<br> EXCEPTIONS<br> http_communication_failure = 1<br> http_invalid_state = 2<br> http_processing_failed = 3 ).<br><br>CALL METHOD lo_http_client->response->get_status<br> IMPORTING<br> code = lv_code<br> reason = lv_reason.<br>
Thanks
Vikash
Request clarification before answering.
See Benedict comment who answers your question (disclaimer: the code with "NEW CL_RSDA_CSV_CONVERTER(...)" leads to a syntax error because CL_RSDA_CSV_CONVERTER is of type "create private", instead instantiate the class by calling the method CL_RSDA_CSV_CONVERTER=>CREATE).
So, your question is about the format that you receive in the HTTP response, which is this text:

So, the format is CSV Comma-Separated Values (the name "Excel format" is meaningless).
The lines are separated by |\r\n| (CRLF). On Unix system, that could be |\n| (LF).
SPLIT lv_result AT |\r\n| INTO TABLE DATA(lines).
NB: you have edited your question and now the code is badly formatted on one line with lots of <br> 😞
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 13 | |
| 8 | |
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.