on 05-11-2010 6:03 AM
Hi,
I have a scenario where I need to read file data from a URL and provide user with Open/Save as/cancel type of pop up box.
How do I achieve it?
Thanks and regards,
Amey
Hi Amey,
Why not just serve the URL directly to the user - via a link UI element? They can then choose to download/save it to local file.
the following code - extracted from method GET_WWW_OBJECT of class CL_UWS_FORM_PDF_API will return an XString of a given URL. (I think this will work from WD ABAP but I am not sure!)
you could then pass this XString to the file download UI element.
DATA:
lo_http_client TYPE REF TO IF_HTTP_CLIENT.
DATA:
lv_str TYPE XSTRING,
lv_i TYPE I.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = iv_url
IMPORTING
client = lo_http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3.
CHECK sy-subrc = 0.
lo_http_client->propertytype_logon_popup = lo_http_client->co_disabled.
lo_http_client->request->set_header_field( EXPORTING name = '~request_method'
value = 'GET' ).
lo_http_client->request->set_header_field( EXPORTING name = '~server_protocol'
value = 'HTTP/1.1' ).
CALL METHOD lo_http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.
CHECK sy-subrc = 0.
CALL METHOD lo_http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
CHECK sy-subrc = 0.
lo_http_client->response->get_status( IMPORTING code = lv_i ).
CHECK lv_i = 200.
lv_str = lo_http_client->response->get_data( ).
rv_content = lv_str.
There is probably a better way of doing this - others may know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you pass the URL file data through WD application parameters?
If so, then you can get it by using application parameter read. Check this [Thread|http://wiki.sdn.sap.com/wiki/display/WDABAP/HowtoreadURLparametersinWebDynprofor+ABAP] for how to get URL parameters.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sanket,
I am not sure whether I conveyed my requirement correctly.
Let me try again.
There will be a Table UI element with three columns --> File Name (String), File URL (string) and Download (Button).
Now on click of "Download" button in table row, I need to open a "Open / Save As/ Cancel" type of pop up box for downloading selected file.
I have done it in WD JAVA where it reads file byte stream from File URL and stores it into a buffer and offers it for download.
I have found this code to open file download pop-up:-
DATA: L_CONTENT TYPE XSTRING .
CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE(
I_FILENAME = P_FILENAME
I_CONTENT = L_CONTENT
I_MIME_TYPE = ''
I_IN_NEW_WINDOW = ABAP_FALSE
I_INPLACE = ABAP_FALSE ) .
But I dont know how do I get XSTRING from File URL.
Thanks and regards,
Amey
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.