04-22-2006 5:27 AM
HI guys,
i had one doubt.
after running a report, i am getting the details. The user shud be given option to save the output. All the details r stored in an internal table. Using AT USER COMMAND, i had given a button on the application tool bar. If the user wants to save, he shud press the button.
Now the problem, the user shud select his own path. If I use gui_download, it is not asking for the path. The pl told not to use the 'Download' fn module.
Is there any way to save the output of the report in the path which the user wants? How to do it?
can anyone tellme how to solve this?
give me one example.
thanks in advance.
vinoth
04-22-2006 7:02 AM
Hi,
Before calling gui_download,call this fm.It will ask for the path.Then assign this path to gui_download path.
data P_FILE LIKE RLGRAP-FILENAME . "Prsnt Srvr
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_PATH = P_FILE
MASK = ',..'
MODE = '0 '
TITLE = 'Choose File'
IMPORTING
FILENAME = P_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
DATA l_file TYPE string.
l_file = p_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = l_file
filetype = 'ASC'
write_field_separator = 'X'
TABLES
data_tab = t_output
EXCEPTIONS
file_write_error = 1
no_batch = 2
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.
MESSAGE s000 WITH text-005.
"Error in downloading file to presentation server
LEAVE LIST-PROCESSING.
ENDIF.
Kindly reward points by clicking the star on the left of reply,if it helps.
04-22-2006 5:32 AM
Hi Vinoth,
Yes you can use the methods of CL_GUI_FRONTEND_SERVICES like FILE_SAVE_DIALOG.
The Function Module looks like this.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
WINDOW_TITLE = 'Save As'
DEFAULT_EXTENSION = ' '
DEFAULT_FILE_NAME = ' '
FILE_FILTER =
INITIAL_DIRECTORY = my_path
WITH_ENCODING =
PROMPT_ON_OVERWRITE = 'X'
CHANGING
filename = file_name
path = file_path
fullpath = file_full
USER_ACTION =
FILE_ENCODING =
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.
Hope your query is solved.
Regards,
SP.
04-22-2006 7:02 AM
Hi,
Before calling gui_download,call this fm.It will ask for the path.Then assign this path to gui_download path.
data P_FILE LIKE RLGRAP-FILENAME . "Prsnt Srvr
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_PATH = P_FILE
MASK = ',..'
MODE = '0 '
TITLE = 'Choose File'
IMPORTING
FILENAME = P_FILE
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
DATA l_file TYPE string.
l_file = p_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = l_file
filetype = 'ASC'
write_field_separator = 'X'
TABLES
data_tab = t_output
EXCEPTIONS
file_write_error = 1
no_batch = 2
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.
MESSAGE s000 WITH text-005.
"Error in downloading file to presentation server
LEAVE LIST-PROCESSING.
ENDIF.
Kindly reward points by clicking the star on the left of reply,if it helps.
04-22-2006 7:11 AM
Hi,
Use the following code to achieve the Result.
1) call file open dialog box
2) call function module to down load; specify file
in my case it is excel sheet u can also use txt
3) specify filter for file type when u open the file dialog box as i had specified based on ur requirment
CONSTANTS :
lc_file_type TYPE char10 VALUE 'DAT',
lc_dft_ext TYPE string VALUE 'XLS',
lc_file_flt TYPE string VALUE '*.xls',
lc_int_drc TYPE string VALUE 'C:\'.
DATA : lit_ty_header TYPE TABLE OF ty_header,
wa_ty_header LIKE LINE OF lit_ty_header,
lv_win_title TYPE string,
lv_file_name TYPE string,
lv_dft_fname TYPE string,
lv_fname TYPE string,
lv_path TYPE string.
--
lv_win_title = text-044.
lv_dft_fname = text-033.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = lv_win_title
default_extension = lc_dft_ext
default_file_name = lv_dft_fname
file_filter = lc_file_flt
initial_directory = lc_int_drc
prompt_on_overwrite = lc_true
CHANGING
filename = lv_fname
path = lv_path
fullpath = lv_file_name
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0 OR lv_fname IS INITIAL
OR lv_path IS INITIAL
OR lv_file_name IS INITIAL.
201: Error occurred while getting file name.
MESSAGE e201(zusm_gen).
EXIT.
ENDIF.
Load Column names to Excel File
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_file_name
filetype = lc_file_type
write_field_separator = lc_true
codepage = '4103'
TABLES
data_tab = lit_ty_header
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 = 0.
Load Data to Excel File
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_file_name
filetype = lc_file_type
append = lc_true
write_field_separator = lc_true
codepage = '4103'
TABLES
data_tab = xt_det_report
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.
ENDIF.
Regards
Manoj
Message was edited by: Manoj Gupta