Skip to Content
author's profile photo Former Member
Former Member

Export to Excel - Getting the control back

I have read a lot of topics in this forum with regards to BSP and Excel and have also found that a few of them have faced the same problem specified below, but I could not find the exact solution on any of the threads, so please help me out.

I am working on a prototype for export to excel. My bsp page has a button and in the DO_HANDLE_EVENT I have the following code

DATA: flights TYPE FLIGHTTAB,
        flight  LIKE LINE OF flights,
        output  TYPE string.

  CONSTANTS: crlf TYPE string VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF,
             tab  TYPE string VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

  SELECT * FROM sflight INTO TABLE flights UP TO 20 ROWS.

  LOOP AT flights INTO flight.
    DATA: seatsmax TYPE string.  seatsmax = flight-seatsmax. CONDENSE seatsmax.
    DATA: seatsocc TYPE string.  seatsocc = flight-seatsocc. CONDENSE seatsocc.
    CONCATENATE output
                flight-carrid     tab
                flight-connid     tab
                flight-fldate     tab
                flight-planetype  tab
                seatsmax          tab
                seatsocc          tab
                crlf
           INTO output.
  ENDLOOP.

* some Browsers have caching problems when loading Excel format
  response->delete_header_field( name = if_http_header_fields=>cache_control ).
  response->delete_header_field( name = if_http_header_fields=>expires ).
  response->delete_header_field( name = if_http_header_fields=>pragma ).

* start Excel viewer either in the Browser or as a separate window
  response->set_header_field( name  = if_http_header_fields=>content_type
                              value = 'application/msexcel' ).
  response->set_header_field( name  = if_http_header_fields=>content_disposition
                              value = 'attachment; filename=webforms.xls' ).

* finally display Excel format in Browser
  response->set_cdata( data = output ).

* do not process Layout, response has been rendered
   navigation->response_complete( ).

when I execute this I get a dialog for open/save/cancel and the download works fine, but whatever option i choose my bsp page is still in processing request mode, how can I get back control to my bsp page.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Jun 13, 2006 at 12:25 PM

    set the content type to

    application/vnd.ms-excel

    and after

    navigation->response_complete( ).

    add

    RETURN.

    Regards

    Raja

    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.