on 10-19-2006 6:21 AM
Hello all,
I want create a BSP page, with 2 radio buttons,
If 1st selected I want read 2 tables and display data other BSP page.
If 2nd one selected I want download 2 tables data into excel file.
Any one can help how to download data into excel file and display data into other bsp page.
Thanks,
Regards,
Venkat
For downloading to a spread sheet:
Convert your fetched data to a string and convert to XSTRING format and finally download to a spread sheet.
Sample: I selected data from vbak say vbeln and kunnr in an internal table.
data : v_string type string, v_xstring type xstring.
<header portion - to have the heading in the spread sheet>
concatenate 'Order Number' 'Customer'
cl_abap_char_utilities=>cr_lf into v_string
separated by cl_abap_char_utilities=>horizontal_tab.
<Line item entries from my internal table say i_vbak>
loop at i_vbak into wa_vbak.
concatenate v_string wa_vbak-vbeln wa_vbak-kunnr
cl_abap_char_utilities=>cr_lf into v_string
separated by cl_abap_char_utilities=>horizontal_tab.
endloop.
All the data is now in string format. Calling the FM to convert to XSTRING
call function 'SCMS_STRING_TO_XSTRING'
exporting
text = v_string
mimetype = 'APPLICATION/MSEXCEL; charset=utf-16le' (probably create this in a variable and call here)
importing
buffer = v_xstring.
concatenate cl_abap_char_utilities=>byte_order_mark_little v_xstring into v_xstring in byte mode.
Now we have it in XSTRING format - this can be downloaded to a spread sheet.
v_appl = 'APPLICATION/MSEXCEL; charset=utf-16le'.
runtime->server->response->set_header_field( name = 'content-type' value = v_appl ).
Eliminating the cache problems when loading Excel Format
runtime->server->response->delete_header_field( name = if_http_header_fields=>cache_control ).
runtime->server->response->delete_header_field( name = if_http_header_fields=>expires ).
runtime->server->response->delete_header_field( name = if_http_header_fields=>pragma ).
Start excel in a separate window
runtime->server->response->set_header_field( name = 'content-disposition' value = 'attachment; filename=Order_list.xls' ).
Displaying the data in excel.
v_len = xstrlen( v_xstring ).
runtime->server->response->set_data( data = v_xstring length = v_len ).
navigation->response_complete( ).
All the above code can be written in onInputprocessing event (probably your loop/selection can be in a method of your appl class).
I believe you are triggering the event based on a click (say radio button or a button after selecting the radiobutton).
In the other screen you can use tableview to display your data - probably two sub screens(page fragment) to display each table.
Regds,
Krish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have followed this thread to export data to an excel file but when the FUNCTION 'SCMS_STRING_TO_XSTRING' ends, the BSP screen frozens and I can't do anything there, only close the window.
What can I do to prevent this?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Venkatesh,
For the doewnload to Xl u create a extension so that it will be reusable .Use this link for that ---
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/756. [original link is broken] [original link is broken] [original link is broken] [original link is broken]
Coming to the 2nd point :
In the oninput processing -
Capture the event and for the function click read data and use Cookies . Use the function modules get_server_cookie ,set_server_cookie,delete_server_cookie
for this.
Please come back in case of any doubts...
regards,
Deepu.k
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.