2006 Nov 09 2:18 PM
Hello friends,
I have downloaded data from Internal table to text file. But my requirement wants it to download in excel sheet.
are there any FM that download data in excel sheet.
Shejal.
2006 Nov 09 2:30 PM
Hi Shejal,
You can use FM GUI_DOWNLOAD.
data: it001 type table of t001 with header line.
select * into table it001 from t001.
call function 'GUI_DOWNLOAD'
exporting
filename = 'C:test.xls'
write_field_separator = 'X'
tables
data_tab = it001.Regards,
Ferry Lianto
Hi Shejal,
You can use FM GUI_DOWNLOAD.
data: it001 type table of t001 with header line.
select * into table it001 from t001.
call function 'GUI_DOWNLOAD'
exporting
filename = 'C:test.xls'
write_field_separator = 'X'
tables
data_tab = it001.Regards,
Ferry Lianto
2006 Nov 09 2:20 PM
Hi shejal,
1. This text file can be opened in excel.
regards,
amit m.
2006 Nov 09 2:22 PM
2006 Nov 09 2:22 PM
hi Shejal,
data lv_file name type string.
data download1 type table (your internal table)
call function 'GUI_FILE_SAVE_DIALOG'
EXPORTING
WINDOW_TITLE = 'Enter File Name'
DEFAULT_EXTENSION = 'XLS'
DEFAULT_FILE_NAME = 'shejal.xls'
IMPORTING
FULLPATH = lv_filename.
call function 'GUI_DOWNLOAD'
exporting
filename = lv_filename
FILETYPE = 'DAT'
tables
data_tab = download1.
This code will download the file in tab delimited form..but will be open with excel...
you can change the delimeter option...by including the file_separator export parameter to gui
_download functin module.
Hope this helps.
Sajan.
2006 Nov 09 2:29 PM
Thanks for all the suggestions,
right now i am downloading the file in tab delimited and opening it in EXCEL.
But the business people dont want to do this. They want it to be downloaded in excel itself.
there anr many files that will be created every hour, so dont want to convert the text file to excel manually.
However I am having one more problem in text file.
Eg- suppose I am downloading two fields,
Kunnr and matnr
when I download they dont want any leading zeros.
so I am having problem with alingment for different rows if the number of char are different,
my output file looks like this.
12345 5632
1234567 5234
125 854889
So I am having problems cnverting into excel.
any suggestions,
Shejal.
2006 Nov 09 2:24 PM
Hi Shejal,
Try this:
A simple option:
a) form download_file .
call function <b>'WS_EXCEL'</b>
importing
filename = excel_name
tables
data = itab.
b) call function <b>'WS_DOWNLOAD'</b>
exporting
filename = o_file
filetype = 'DAT'
tables
data_tab = i_tab
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
others = 11.
if sy-subrc = 0.
message 'File is downloaded successfully' type 'I'.
endif.
CALL FUNCTION <b>'SAP_CONVERT_TO_XLS_FORMAT'</b>
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER =
i_filename =
I_APPL_KEEP = ' '
tables
i_tab_sap_data =
CHANGING
I_TAB_CONVERTED_DATA =
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Another FM
<b>MS_EXCEL_OLE_STANDARD_DAT</b>
Reward points if this helps.
Manish
Message was edited by: Manish Kumar
2006 Nov 09 2:30 PM
Hi Shejal,
You can use FM GUI_DOWNLOAD.
data: it001 type table of t001 with header line.
select * into table it001 from t001.
call function 'GUI_DOWNLOAD'
exporting
filename = 'C:test.xls'
write_field_separator = 'X'
tables
data_tab = it001.Regards,
Ferry Lianto
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |