on 02-11-2014 10:54 AM
Hi to all,
i'm developing a new bsp and i need to download more files;
for download file i use this method: CALL METHOD cl_bsp_utility=>download
1.Convert the text to a text table ie Internal table with a line type char255 or some others.
2.Convert the text table into a string.
3.Convert the string to XSTRING.
4.Download that XSTRING as text file using the method
CL_BSP_UTILITY=>download.
if I download 1 file its all ok but if I try to download 2 files on click button the system always download the latest;
why?...how can I download 2 or more files on click button?
regard.
swb
Maybe creating a single zip file containing the two files you want to download would provide a better solution. For example:
DATA: lr_zip TYPE REF TO cl_abap_zip,
lv_xstring TYPE xstring.
data: lv_zip_xstring TYPE xstring.
CREATE OBJECT lr_zip. "Create instance of Zip Class
*File 1 content in string lv_string1
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = lv_string1
mimetype = 'APPLICATION/MSEXCEL;charset=utf-16le'
IMPORTING
buffer = lv_xstring.
lr_zip->add( name = 'File1.xls'
content = lv_xstring ).
*File 2 content in string lv_string2
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = lv_string2
mimetype = 'APPLICATION/MSEXCEL;charset=utf-16le'
IMPORTING
buffer = lv_xstring.
lr_zip->add( name = 'File2.xls'
content = lv_xstring ).
* Get the binary stream for ZIP file
lv_zip_xstring = lr_zip->save( ).
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
lv_app_type = 'APPLICATION/zip'.
CALL METHOD cl_bsp_utility=>download
EXPORTING
object_s = lv_zip_xstring
content_type = lv_app_type
content_disposition = 'attachment;filename=File.zip'
response = runtime->server->response
navigation = navigation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure how a serious requirement can reject a zipped file solution to this problem as the end user gets all the file in the end just the same, especially since you've had this issue open for months.
Also, I think what you are asking for might be outside the standard browser capabilities although there are a few work arounds suggested in this thread:
http://stackoverflow.com/questions/2339440/download-multiple-files-with-a-single-action
Are you giving a different file names to your second download in parameter content_disposition? E.g.
*first file
CALL METHOD cl_bsp_utility=>download
EXPORTING
object_s = lv_xstring
content_type = lv_app_type
content_disposition = 'attachment;filename=File1.xls'
response = runtime->server->response
navigation = navigation.
*second file
CALL METHOD cl_bsp_utility=>download
EXPORTING
object_s = lv_xstring
content_type = lv_app_type
content_disposition = 'attachment;filename=File2.xls'
response = runtime->server->response
navigation = navigation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Swb,
I'm afraid that my last suggestion won't work. In fact, I don't think this method can be used to down load multiple files in one server round trip as it uses the http response to instruct the browser to start downloading and so as you have been finding if you call it twice in one server round trip the first call is overwritten with the second. You could always try to force this method my by having two server round trips - trigger a second event after the first call to this method so that the second download start as soon as the page has reloaded.
Not user what you mean by reload BSP, the page should reload after each server round trip. If you mean return to some initial state you will have to program this yourself.
I'll try and offer some more constructive suggestions about this issue if I get a chance.
Points are always appreciated if you find a suggestion helpful.
Hi swb,
You may use GET_WITH_TABLE or GET_WITH_FILE or GET_WITH_URL methods of class CL_CRM_DOCUMENTS. For single file i used GET_WITH_URL method but for multiple files u can use loop.
And for uploading files we had used same class method (CREATE_WITH_TABLE).
Regards
Dewansh Sharma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Swb
"Get all the details of the file
DATA:LV_RAW TYPE XSTRING.
DATA:LT_RAW TYPE SDOKCNTBINS.
DATA:LV_FILE_NAME TYPE SDOK_FILNM.
DATA: LV_MIME_TYPE TYPE STRING.
DATA LV_FILE_SIZE TYPE I.
DATA:DATA TYPE REF TO CL_HTMLB_FILEUPLOAD.
data ?= CL_HTMLB_MANAGER=>GET_DATA(
request = runtime->server->request
name = 'fileUpload'
id = 'file_upload_id'
).
LV_FILE_name = data->FILE_NAME. "FILE NAME
LV_RAW = data->FILE_CONTENT. "FILE CONTENT IN XSTRING
LV_MIME_TYPE = data->FILE_CONTENT_TYPE. "MIME TYPE
LV_FILE_SIZE = data->FILE_LENGTH. "FILE SIZE
call function 'SCMS_XSTRING_TO_BINARY' "CONVERT THE CONTENT TO BINARY
exporting
buffer = LV_RAW
append_to_table = 'X' "Do not clear/refresh table
tables
binary_tab = LT_RAW.
"CREATE OBJECT OF CL_CRM_DOCUMENTS
"CALL METHOD CREATE_WITH_TABLE
"AND SEND THE ABOVE INFORMATION AS IMPORTING PARAMETER TO THE METHOD CREATE_WITH_TABLE
Regards
Dewansh Sharma
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.