data: begin of it_header occurs 0,
header(30) ,
end of it_header.
move 'FIELD NAME1' to it_header-header.
append it_header.
move ' FIELD NAME2' to it_header-header.
append it_header.
move ' FIELD NAME3' to it_header-header.
append it_header.
move ' FIELD NAME4' to it_header-header.
append it_header.
move ' FIELD NAME5' to it_header-header.
append it_header.
*Method to POP Up the file path to save
call method cl_gui_frontend_services=>file_save_dialog
exporting
* window_title = ' '
default_extension = 'XLS'
default_file_name = lf_save_filename
initial_directory = 'c:\temp\'
changing
filename = lf_save_filename
path = lf_save_filepath
fullpath = lf_save_filefullpath
user_action = lf_result.
* Check user did not cancel request
check lf_result eq '0'.
*Function module to download the internal table data into excel
call function 'GUI_DOWNLOAD'
exporting
filename = lf_save_filename
filetype = 'ASC'
* HEADER = it_header
* APPEND = 'X'
write_field_separator = 'X'
* CONFIRM_OVERWRITE = 'X'
tables
data_tab = lt_result[] "need to declare and populate
fieldnames = it_header[]
exceptions
file_open_error = 1
file_write_error = 2
others = 3.
ABAP methods to download internal table contents into Excel
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment