09-08-2008 9:59 AM
Hi all,
I want to download the output of classical report to an excel file. I have used the following function:
CONCATENATE 'e:\' 'sap.txt' INTO fna.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = fna
FILETYPE = 'ASC'
tables
data_tab = it_final.
IF sy-subrc = 0.
MESSAGE s005 with fna.
ENDIF.
now this function is coverting the output into a normal text file in a notepad.. When I give the file type as 'XLS', it gives an error saying that the value of parameter filetype is not correct.
please tell me about what can be the possible method for fulfilling my requirement
Regards,
Nikita
09-08-2008 10:02 AM
HI,
Give the file name as SAP.xls not SAP.txt.
Give FILETYPE = 'ASC'.
Regards
Sumit Agarwal
09-08-2008 10:02 AM
HI,
Give the file name as SAP.xls not SAP.txt.
Give FILETYPE = 'ASC'.
Regards
Sumit Agarwal
09-08-2008 10:03 AM
Hi....
Giving sample code...
data: p_file type string,
p_path type string.
perform fill_titles. <------ fill the titile table here
p_file = 'file.xls'.
call method cl_gui_frontend_services=>file_save_dialog
exporting
default_file_name = p_file
changing
filename = p_path
path = p_path
fullpath = p_file
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
if p_file is initial.
message 'failed' type 'E'.
endif.
call function 'gui_download'
exporting
* BIN_FILESIZE =
filename = p_file
filetype = 'dat'
* APPEND = ' '
write_field_separator = 'x'
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = i_hold
fieldnames = titles_it
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22.
if sy-subrc ne 0.
endif.
endif.
Thanks,
Naveen.I
09-08-2008 10:04 AM
Hi Nikita,
If you want to download an Excel file for the o/p
Then let the FILETYPE = 'ASC'.
Make changes to the variable fna
Make it CONCATENATE 'e:\' 'sap.xls' INTO fna.
This will help
Regards,
Prashant
09-08-2008 10:05 AM
hii
your code is correct jst check with following code too and try changing FILETYPE as DBF.
DATA:
lw_file TYPE string .
" File Path
lw_file = p_pfile. -----------------------> give file as .XLS type
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lw_file
filetype = 'DBF'
write_field_separator = 'X'
IMPORTING
FILELENGTH = FILELENGTH
TABLES
data_tab = i_output
fieldnames = i_final
regards
twinkal
09-08-2008 10:09 AM
Hi NIKITA,
Everything you had done is fine except CONCATENATE 'e:\' 'sap.txt' INTO fna.
change it as CONCATENATE 'e:\' 'sap.xls' INTO fna.
This would solve your issue.
Good luck
Narin
09-08-2008 10:20 AM
09-08-2008 10:33 AM
Thank u sumit n thank u all for solving my problem... I was doing a silly mistake..
cheers,
Nikita