Hallo,
villeicht hilt es jemand, wenn ich mein Coding veröffentliche. Es ist nicht ganz sauber. Ist halt nur Testcoding. Den Key in der Url habe ich weggelassen.
Die Response wird im Html-Viewer ausgegeben
report zll_testws line-size 1023 .
data: l(256),
i type i.
data: o_cont type ref to cl_gui_custom_container,
o_hv type ref to cl_gui_html_viewer,
ok_code type syucomm.
data: client type ref to if_http_client,
url type string.
****Build the Sending URL
concatenate
'
http://api.google.com/search/beta2'
`&key=`
` ?!?!?`
`&q=`
`Star Wars`
into url.
****Create the HTTP client
call method cl_http_client=>create_by_url
exporting
url = url
* ssl_id = 'page_srv-ssl_id'
proxy_host = 'proxy'
proxy_service = '8080'
importing
client = client
exceptions
others = 1.
***!!!!!!!!!!!!!!!
****Set the Request type to GET
client->request->set_header_field( name = '~request_method'
value = 'GET' ).
****Make the call
client->send( ).
***!!!!!!!!!!!!!!!!!!!!
****Receive the Response Object
call method client->receive
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
others = 4.
****Get the response content in Character format
data: p_content type string.
p_content = client->response->get_cdata( ).
set screen 0100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0100 output.
data: ll(256),
lt like table of ll,
li type i,
m type i,
x_do type i,
x_rest type i.
m = 0.
i = 0.
m = strlen( p_content ).
x_rest = m mod 256.
x_do = m div 256.
*if x_rest > 0.
add 1 to x_do.
*endif.
if not p_content is initial.
do x_do times.
subtract 1 from x_do.
if x_do <= 1.
if x_rest = 0.
exit.
endif.
li = x_rest.
else.
li = 256.
endif.
ll = p_content+i(li).
add 256 to i.
append ll to lt.
if x_do = 1. exit. endif.
enddo.
endif.
set pf-status '0100'.
* SET TITLEBAR 'xxx'.
append p_content to lt.
create object o_cont
exporting
container_name = 'CC'.
create object o_hv
exporting
parent = o_cont.
call method o_hv->load_data
importing
assigned_url = hurl
changing
data_table = lt.
call method o_hv->show_url
exporting
url = hurl.
endmodule. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module user_command_0100 input.
if sy-ucomm = 'BACK'.
leave to screen 0.
endif.
endmodule. " USER_COMMAND_0100 INPUT