Skip to Content
0
Former Member
Jul 27, 2005 at 08:49 PM

Download to Excel

124 Views

I have a BSP application which is MVC based. When a user clicks on the button of a controller I set cookie on the server side and call a page of flow logic to get the cookie. As the model variables are no more accessible I have to set and get the cookie.

Problem.

After getting the cookie I call several methods to download the data to Excel. The data is extracted correctly but the window of the page of flow logic doesn’t close.

Here is the code on the page of flow logic.

<u><i><b>PROBLEM 1</b></i></u>

<b>LAYOUT</b>

<%@page language="abap" %>

<%@extension name="htmlb" prefix="htmlb" %>

<htmlb:content design="DESIGN2003" >

<htmlb:document disableBackspaceNavigation="TRUE" >

<htmlb:documentHead title="BPR Main Application" >

</htmlb:documentHead>

<htmlb:documentBody>

<htmlb:form>

<script language="JavaScript" type="text/javascript">

window.opener = parent;

window.opener.close();

</script>

</htmlb:form>

</htmlb:documentBody>

</htmlb:document>

</htmlb:content>

<b>

OnInitialisation</b>

DATA: date TYPE d,

time TYPE t,

app_type TYPE string value 'application/xls',

l_len TYPE i,

filename TYPE string.

date = sy-datum + 1.

time = sy-uzeit.

cl_bsp_server_side_cookie=>get_server_cookie(

EXPORTING

name = 'download'

application_name = runtime->application_name

application_namespace = runtime->application_namespace

username = sy-uname

session_id = runtime->session_id

data_name = 'download'

IMPORTING

expiry_date = date

expiry_time = time

CHANGING

data_value = l_string ).

response->set_header_field( name = 'content-type' value = app_type ).

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 ).

CONCATENATE 'attachment; filename='

'BPR'

'.xls'

INTO

filename.

response->set_header_field( name = 'Content-Disposition' value = filename ).

l_len = STRLEN( l_string ).

response->set_cdata( data = l_string length = l_len ).

navigation->response_complete( ).

When I comment this piece of code the window closes

response->set_header_field( name = 'Content-Disposition' value = filename ).

<u><i><b>

PROBLEM 2</b></i></u>

When I place the code of the OnInitialisation in DO_HANDLE_EVENT and don’t set any cookie the downloads takes place successfully but the the pop window for the protect double submit doesn’t go away.

<b><u><i>Where am, I wrong ???</i></u></b>

Regards

Amandeep