‎2007 Feb 20 2:41 PM
Hi,
When we use FM GUI_DOWNLOAD it saves internal table into excel file in a 'Text-Tab delimited format' . Is there any FM which will store the contents in MICROSOFT EXCEL WORKBOOK format??
‎2007 Feb 20 2:44 PM
Refer this code
http://www.sapdevelopment.co.uk/file/file_uploadpc.htm
http://www.sapdevelopment.co.uk/file/file_updown.htm
Specify .xls instead of .txt
Reward points if u find helpful.
‎2007 Feb 20 2:45 PM
Hi Abhijeet,
the same fm can be used to download to EXCEL as well.
Just that you need to specify the file name as <Name>.xls. and pass the
HAS_FIELD_SEPARATOR = 'X'.
Regards,
Ravi
‎2007 Feb 20 2:46 PM
Hi Abhijit,
For downaloading to Excel file you can sipmly give the extension of file name as .xls. It will create a excel file on presentation server.
Reward points if helpful answer.
Ashvender
‎2007 Feb 20 2:47 PM
use GUI_DOWNLOAD and in file name specify as tab.xls along with
HAS_FIELD_SEPARATOR = 'X'.
‎2007 Feb 20 2:48 PM
Hi all,
I am facing the same prob as Abhijeet is having.. I have tried all options u hve suggested.. Gui_download is nt working for that.
after downloading into excel format using(gui_download), if i changed the data in the excel sheet and try to save the data it directly goes to save as dialogue box.
using gui_download , it saves the data in text(tab delimited format) but it should save it as in the format microsoft work book.
if any body has the solution plaese tell me...its urgent..
Hari
‎2007 Feb 20 3:16 PM
USe the FM ASLM_EXCEL_TO_INTERNAL_TABLE This will Definately Work.After See ing this Give some points.
‎2007 Feb 21 6:08 AM
Hi anilkumar,
My problem is while downloading internal table to excel file. but the FM you told is for excel to internal table.
‎2007 Feb 21 7:03 AM
Hi,
Please use the following code,
DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm,
lv_file(80),
lv_fieldln TYPE i,
lv_def_path TYPE rlgrap-filename,
lv_mode TYPE c VALUE 'S',
lv_tmp_filename TYPE rlgrap-filename,
lv_tmp_mask(80).
FIELD-SYMBOLS: <fs_tmp_sym>.
save_ok = ok_code.
CASE save_ok.
WHEN 'EXCEL'.
*--- On click of 'Download to Excel' button transfer the ALV data to
*--- Excel sheet.
lv_tmp_mask = ',.,..'.
lv_fieldln = strlen( lv_def_path ) - 1.
ASSIGN lv_def_path+lv_fieldln(1) TO <fs_tmp_sym>.
IF <fs_tmp_sym> = '/' OR <fs_tmp_sym> = '\'.
CLEAR <fs_tmp_sym>.
ENDIF.
*--- Get the file name & path to which file has to be downloaded.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_path = lv_def_path
mask = lv_tmp_mask
mode = lv_mode
IMPORTING
filename = lv_tmp_filename
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc = 0.
*--- As we need to download the file in 'XLS' format add the
*--- extension '.XLS' if it is not provided by the user.
IF NOT lv_tmp_filename CS c_excel.
CONCATENATE lv_tmp_filename c_excel INTO lv_file.
ELSE.
lv_file = lv_tmp_filename.
ENDIF.
ELSE.
EXIT.
ENDIF.
*--- Down load the file to the path and filename provided above.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = lv_file
filetype = 'DAT'
TABLES
data_tab = gt_excel1
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
OTHERS = 10.
IF sy-subrc = 0.
MESSAGE i000(zf) WITH text-017.
ELSE.
MESSAGE e939(zf) WITH lv_file. "Errors while downloading.
ENDIF.
ENDCASE.
****************
gt_excel1 is the internal table you provide to the FM for downloading.
lv_file is automatically taken care of from the input provided by the user.
The above code is triggered when a button in Application tool bar is clicked. Please use it as needed. It will ask for the path to which file has to be downloaded and once provided it will download the table only to excel.
You can also use GUI download and pass the internal table appropriately.
It will work for sure.
Regards,
Paul.
‎2007 Feb 21 7:11 AM
Thanks paul your code really helpfull.
Even i have used SAP_CONVERT_TO_XLS_FORMAT after gui_download & it is working fine.
Thanks lot.
‎2007 Feb 21 7:23 AM