cancel
Showing results for 
Search instead for 
Did you mean: 

How to let user download multi files at the same time in WebDynpro ABAP?

tony_zheng
Explorer
0 Kudos

hi all:

As you know, WeyDynpor has provided upload/download UI element, but it seems that it only support one file upload/downlaod at the same time.The following is the API method to download one file in Webdynpro:

cl_wd_runtime_services=>attach_file_to_response(

EXPORTING

i_filename = lv_filename

i_content = lv_content

i_mime_type = lv_mine_type

i_in_new_window = abap_true

i_inplace = abap_false

* EXCEPTIONS

* others = 1

).

but if when use click one button, we want to provide user a html file plus 2 icons files which are used as this html file's resource file, then how to let user download these 3 files together at the same time?

one simple way is calling the download api (cl_wd_runtime_services=>attach_file_to_response) 3 times,

but it is very ugly that three popup windows are shown to let user select every file's download path, which is unaccepted.

So anyone know more convienient way to handle it?

thanks.

Accepted Solutions (1)

Accepted Solutions (1)

ChrisPaine
Active Contributor
0 Kudos

Hello Tony,

sorry - it's not supported in any standard UI element at the moment.

Your best bet is to build a flex island - that does have the ability to take multiple files - and get it to load them into your context.

Depending on your version - you also have the option of a silverlight island.

It would be nice if it was supported as standard - just in case anyone is listening!

Hope this helps,

Chris

tony_zheng
Explorer
0 Kudos

thanks for your suggestion, but we are not allowed to use flex or silverlight. so we must get a suitable solution or workaround.

Hope Basis could enhance the standard UI element in the future.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Zipping the files is a very good workaround.

>sorry - it's not supported in any standard UI element at the moment.

Actually there is a standard UI element that this can be done with as of 7.01. It is the ACFUpDownload. It does require writting your own HTTP handler to service the download - since ACFUpDownload doesn't communicate directly with your Web Dynpro session. However this can be done without too much difficulty. The ACFUpDownload does have the downside that it doesn't have a file open/save dialog (at least until 7.02) and it requires a security whitelist to control which directories are accessible.

For what you described Zip content is probably still the best approach, but just wanted to present alternatives for future consideration.

Answers (1)

Answers (1)

bjorn-henrik_zink
Active Participant
0 Kudos

Hi,

I suggest you to zip the files and attach it to the response. Do the add file part for each of your files


     "References
     DATA lr_zip TYPE REF TO cl_abap_zip.

     "Variables
     DATA lv_zip_xstring TYPE xstring.
     DATA lv_zip_name TYPE string.
     DATA lv_file_content TYPE xstring.
     DATA lv_file_name  TYPE string.

     "Create instance
     CREATE OBJECT lr_zip.

     "Add file
     lr_zip_attachments->add( 
       EXPORTING name = lv_file_name
              content = lv_file_content ).

     "
     lr_zip_attachments->save( RECEIVING zip = lv_zip_xstring ).

     "Attach zip file to response
     cl_wd_runtime_services=>attach_file_to_response(
       EXPORTING i_filename      = lv_zip_name 
                 i_mime_type     = 'ZIP/APPLICATION'
                 i_content       = lv_zip_xstring ).

tony_zheng
Explorer
0 Kudos

yes, this is an accepted workaround, thanks

and moreover, the mime type of zip file is 'application/zip', not 'zip/application', right?

Edited by: Tony Zheng on Mar 31, 2010 10:27 AM

Edited by: Tony Zheng on Mar 31, 2010 10:28 AM

bjorn-henrik_zink
Active Participant
0 Kudos

Of course you are right, it should be application/zip as mime type.