cancel
Showing results for 
Search instead for 
Did you mean: 

download without save dialog

Former Member
0 Kudos

Hi,

I use the method below to download attachment from BSP.


      lv_contenttype = 'application/octet-stream'.

          CONCATENATE 'attachment; filename=' lv_name
            INTO lv_contentdisposition.

          CALL METHOD runtime->server->response->set_header_field
            EXPORTING
              name  = 'content-disposition'
              value = lv_contentdisposition.

          CALL METHOD runtime->server->response->set_header_field
            EXPORTING
              name  = 'content-type'
              value = lv_contenttype.

          CALL METHOD runtime->server->response->set_header_field
            EXPORTING
              name  = 'content-filename'
              value = lv_name.

        lv_chunksize = 1022.
        LOOP AT lt_contents INTO ls_contents.
          MOVE ls_contents-line TO xwa.
          xwa_len = lv_file_size - ( lv_chunksize * ( sy-tabix - 1 ) ).

          IF xwa_len >= lv_chunksize.
            xwa_len = lv_chunksize.
          ENDIF.
          runtime->server->response->append_data( data   = xwa
                              length = xwa_len ).
        ENDLOOP.

        navigation->set_parameter( name  = 'content_length'
                                   value = lv_file_size ).
        runtime->server->response->delete_header_field(
                  name = 'Cache-Control' ).
        runtime->server->response->delete_header_field(
                  name = 'Expires' ).
        navigation->response_complete( ).

But this only allow to download 1 attachment at each time?

I have a service ticket that tight with few attachments. On my BSP page, there is a download button, is it possible to download those attachments at the same time to desktop and without saving dialog pop out?

Kindly advise.

thanks,

ginnie

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Ginnie,

I think Patrick is correct here. With IE you do not have the possibility to avoid the dialog. In Firefox it might be possible if the user has set a standard directory to save downloaded files to. But this configuration must be done on the client. You cannot control that from the server side of things (and if you think about it this is definitly a good thing as I don't want a server admin to store data anywhere on my hard drive).

Regarding the multiple attachments: there are function modules on the NetWeaver application server to zip files into an archive. So I would recommend building an archive and sending the zip file back to the user. If I remember correct there is a weblog on SDN showing this exact thing (zipping multiple files into one archive and sending them back to the client).

Best regards,

Alexander

Former Member
0 Kudos

Hi Patrick & Alexander,

Thanks for the valuable answer!!

@Alexander, I am searching on the weblog that you mentioned. One of the method is using command line, which i am using now.

I use the <b>cl_gui_frontend_services=>execute</b> to execute a .bat file which contains of command line to zip. This seems to be worked well in either program or FM, but not in BSP. Do you have any suggestion on this?

Thanks & Regards,

ginnie

guillaume-hrc
Active Contributor
0 Kudos

Hi Ginnie,

You <b>cannot use class CL_GUI_FRONTEND_SERVICES</b> which requires a direct connection with the OS of the user (through SAP GUI for instance). In a Web environment, this is not the case.

In general, you cannot interact with files or executables on the client side from BSP.

What I would suggest is simply to ZIP the whole set of files on the server-side and push them to the client to take care of it (store it, unzip it, ...).

Look at this thread which contains helpful hints:

Best regards,

Guillame

Former Member
0 Kudos

Hi,

Thanks for the reply!!

I also found another thread which has solved my problem. <b>cl_doc_zipper</b> can zip all files together and use FM GUI_DOWNLOAD to download it in .zip format.

regards,

ginnie

Patrick_McMahon
Contributor
0 Kudos

Hi Ginnie,

As far as I am aware this is the only method. The dialog popup is to prevent malicious code being run in browser without user intervention so it cannot be turned off.

Regards,

Patrick.