Skip to Content
0
Former Member
Jun 13, 2006 at 11:55 AM

Export to Excel - Getting the control back

16 Views

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.