Skip to Content

BSP Download - Response is running for a long time.

Hi All,

I have used the method cl_bsp_utility=>download to download the data to excel file. After clicking on download button the response is running for long time and not completing. Please advice how to get the control back to page. Thanks.

CALL METHOD cl_bsp_utility=>download
object_s = l_xstring
content_type = app_type
content_disposition = 'attachment;filename=CompletedCourse.xls'
response = runtime->server->response
navigation = navigation.


Ganesh R K.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Jul 31, 2012 at 01:54 PM

    Hi Ganesh,

    I tried with a plain HTML BSP page, and without using the CL_BSP_UTILIES=>DOWNLOAD method. It works fine in my case. Of course, I do get the question whether I want to open or save the downloaded document. That's normal. But when hitting the button, my Excel is downloaded to the computer and when I choose "open", Excel starts and displays the 3x3 magic square.

    By the way, this showed me that the file ending .xls together with the MIME type application/ works fine (contrary to my recommendation to change this to text/csv).

    Maybe this running example of an Excel download page helps you in any way.



    P.S.: I don't understand your print question. It should be clear that you can print an Excel sheet only from within Excel. To print the HTML page, use the method print() of the window object. Or what do you want to print?

    <%@page language="abap"%>
    <% if request->get_form_field('download') eq 'X'.
    data: lv_bin type xstring,
    lv_csv type string,
    lv_row type string,
    lv_text type string,
    lv_length type string,
    lo_conv type ref to cl_abap_conv_out_ce. define _add_cols.
    concatenate &1 &2 &3 into lv_row
    separated by cl_abap_char_utilities=>horizontal_tab.
    if lv_csv is not initial.
    concatenate lv_csv lv_row into lv_csv
    separated by cl_abap_char_utilities=>cr_lf.
    lv_csv = lv_row.
    end-of-definition. _add_cols:
    '10' '2' '3', " Du musst verstehn, aus 1 mach 10, die 2 lass gehn, die 3 mach gleich
    '0' '7' '8', " Verlier die 4, aus 5 und 6, so sagt die Hex, mach 7 und 8
    '5' '6' '4'. " So ist's vollbracht. lo_conv = cl_abap_conv_out_ce=>create( ).
    lo_conv->convert( exporting data = lv_csv importing buffer = lv_bin ). response->set_header_field( name = 'Content-Type'
    value = 'application/; charset=utf-8' ).
    lv_length = xstrlen( lv_bin ).
    response->set_header_field( name = 'Content-Length'
    value = lv_length ).
    response->set_header_field( name = 'Content-Disposition'
    value = 'attachment;filename=text.xls' ).
    response->delete_header_field( name = 'Expires' ).
    response->delete_header_field( name = 'Pragma' ).
    response->delete_header_field( name = 'Cache-control' ). response->set_data( lv_bin ). else. %>
    <head>Test Download</head>
    <h1>Test Download</h1>
    <form method="post">
    <input type="hidden" name="download" value="X">
    <input type="submit" name="Download">
    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Rudiger,

      I have solved that issue. Add the below code to stop the doublesubmit process. Many thanks for your help.

      function wait_timeout()


      window.setTimeout('showProtectDoubleSubmitWindow(false)', 4000);
      window.setTimeout('showProtectActive = null', 4010);

      <htmlb:button id = "submit"
      text = "Download"
      onClick = "test"
      onClientClick = "wait_timeout( );"
      width = "5%"/>


      Ganesh R K.

  • Posted on Jul 31, 2012 at 09:28 AM
    Hi Ganesh, I don't use CL_BSP_UTILITY=>DOWNLOAD, but I inspected its implementation. I saw that the statements
    *  length = xstrlen( <os> ).
    * response->set_header_field( name = 'Content-Length'
    * value = length ).
    have been commented out in the implementation. Oddly, in similar case with a pdf download, I had just your symptom - the Internet Explorer waiting indefinitely for the completion of the download - due to the missing field Content-Length. Therefore: Please set Content-Length before the call of CL_BSP_UTILITY=>DOWNLOAD. (You can set header fields before the call, too. ) Another problem could be with the encoding. The download method expects binary data (raw data, an xstring), whereas Excel data (probably csv), will be given as character sequence (string). In this case, you must have mapped your character data to an XSTRING before calling CL_BSP_UTILITY=>DOWNLOAD. Do not use XSTRLEN( ) as Content-Length then, but STRLEN( ) for the original , since you will have to count characters, not bytes. Regards, Rüdiger
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.