I have in my abap program an internal table with several rows of data. I loop over the table and call the same BSP page for each entry.
The goal is to read the data of each line in HTML format and then download it as an HTML file.
Problem is:
the first call (first run) works perfectly and returns html text, but on next calls (next data lines) the method http_client->response->get_cdata( ) does not return any data, even though everything ran without errors (response status = 200).
I ask for help!
here is the call logic:
loop at it_data .....
......
......
CALL METHOD cl_http_ext_webapp=>create_url_for_bsp_application
EXPORTING
bsp_application = iv_app
bsp_start_page = iv_page
bsp_start_parameters = lt_params
IMPORTING
abs_url = lv_url.
* Create internal http client
CALL METHOD cl_http_client=>create_internal
IMPORTING
client = lr_http_client
EXCEPTIONS
plugin_not_active = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
ev_error = abap_true.
RETURN.
ENDIF.
cl_http_utility=>set_request_uri( request = lr_http_client->request
uri = lv_url ).
lr_http_client->request->set_header_field( name = '~request_method'
value = 'GET' ).
* Send and recieve
lr_http_client->send(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
http_invalid_timeout = 4
OTHERS = 5
).
IF sy-subrc = 0.
lr_http_client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4
).
ENDIF.
IF sy-subrc <> 0.
CALL METHOD lr_http_client->get_last_error
IMPORTING
code = lv_rc
message = lv_message.
ev_error = abap_true.
RETURN.
ENDIF.
lr_http_client->response->get_status( IMPORTING code = lv_rc
reason = lv_reason ).
IF lv_rc = 200.
ev_html = lr_http_client->response->get_cdata( ).
ELSE.
ev_error = abap_true.
RETURN.
ENDIF.
lr_http_client->close( ).
endloop.
Two more points:
I edited the code so that the htp_client instance is created outside the loop (call cl_http_client=>create_internal() ), but unfortunately it didn’t work either.
I debugged it, the request went through to the BSP app (page) every time for every data entry, but I can’t track where the data is lost afterwards!!
Thanks in advanced.
Mhsoftware is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.