on 10-13-2008 12:30 PM
I have used the FileDownload option to download the file by seeing WDR_TEST_EVENTS. Using that i am downloading the file in TXT format. But i want the file in CSV Format. How can i get this ?
Hi Manjunath,
Below is the solution if you aren't to use the FileDownload UI element.
1) First read the table's data into an internal table.
2) Convert the internal table data to STRING format.
3) Now convert it into tab separated format as how desired.
4) Convert this STRING format to XSTRING format
5) Make use of the attach_file_to_response method.
You can also go through[ this link|http://saptechnical.com/Tutorials/WebDynproABAP/Export/toexcel.htm] for a similar example.
Regards,
Uday
METHOD onactionon_submit .
DATA: lv_node TYPE REF TO if_wd_context_node,
lt_mara TYPE if_main=>elements_mara,
wa_mara TYPE if_main=>element_mara,
lead_selection_index TYPE i,
mara_string TYPE string,
mara_xstring TYPE xstring.
lv_node = wd_context->get_child_node( name = 'MARA' ).
CALL METHOD lv_node->get_static_attributes_table
IMPORTING
table = lt_mara.
LOOP AT lt_mara INTO wa_mara.
CONCATENATE mara_string
wa_mara-matnr
wa_mara-ersda
wa_mara-ernam
wa_mara-matkl
wa_mara-meins
cl_abap_char_utilities=>newline INTO mara_string
SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
ENDLOOP.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = mara_string
IMPORTING
buffer = mara_xstring.
wdr_task=>client_window->client->attach_file_to_response( i_filename = 'TEMP.DOC'
i_content = mara_xstring
i_mime_type = 'WORD' ).
ENDMETHOD.
The above is the code to export the Internal Table to Word Document. You can proceed as shown below for Excel & NOTEPAD formats.
To Export the Internal Table to Text File:
WDR_TASK=>CLIENT_WINDOW->CLIENT->ATTACH_FILE_TO_RESPONSE(
I_FILENAME = 'WDP.txt'
I_CONTENT = mara_xstring
I_MIME_TYPE = 'NOTEPAD' ).
To Export the Internal Table to Excel File:
WDR_TASK=>CLIENT_WINDOW->CLIENT->ATTACH_FILE_TO_RESPONSE(
I_FILENAME = 'Excel.xls'
I_CONTENT = mara_xstring
I_MIME_TYPE = 'EXCEL' ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.