‎2008 Aug 18 6:03 AM
Hi,
I have a requirement where I will have to download a file temporarily and open it in the front end.. Now I need to download the file to the users SAP Working directory. how do i determine the directory path?
I think usually it has the path
C:\Documents and Settings\<current windows user name>\SapWorkDir
plz suggest. I have tried using the obsolate function module REGISTERY_GET, but didnt know how to use it.. and, well the FM was suggesting me to use the methods of class CL_GUI_FRONTEND_SERVICES, but didnt know how to use it too..
Thanx in advance..
‎2008 Aug 18 9:41 AM
REPORT ztest.
DATA: workdir TYPE sdok_chtrd,
errmsg TYPE iwerrormsg,
length TYPE I.
DATA: filename TYPE string,
fullpath TYPE string,
user_action TYPE i,
path TYPE string,
intd type string.
CALL FUNCTION 'IW_C_GET_SAPWORKDIR'
IMPORTING
sapworkdir = workdir
error_msg = errmsg.
intd = workdir.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = 'Save as...'
with_encoding = 'X'
initial_directory = intd
CHANGING
filename = filename
path = path
fullpath = fullpath
user_action = user_action
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc NE 0 OR user_action NE cl_gui_frontend_services=>action_ok.
EXIT.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = fullpath
filetype = 'DAT'
write_field_separator = ','
IMPORTING
filelength = length
TABLES
data_tab = gt_tickets
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.
‎2008 Aug 18 9:41 AM
REPORT ztest.
DATA: workdir TYPE sdok_chtrd,
errmsg TYPE iwerrormsg,
length TYPE I.
DATA: filename TYPE string,
fullpath TYPE string,
user_action TYPE i,
path TYPE string,
intd type string.
CALL FUNCTION 'IW_C_GET_SAPWORKDIR'
IMPORTING
sapworkdir = workdir
error_msg = errmsg.
intd = workdir.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = 'Save as...'
with_encoding = 'X'
initial_directory = intd
CHANGING
filename = filename
path = path
fullpath = fullpath
user_action = user_action
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc NE 0 OR user_action NE cl_gui_frontend_services=>action_ok.
EXIT.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = fullpath
filetype = 'DAT'
write_field_separator = ','
IMPORTING
filelength = length
TABLES
data_tab = gt_tickets
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.
‎2008 Aug 18 9:46 AM
Hi,
use the method get_sapgui_workdir of class cl_gui_frontend_services.
call method cl_gui_frontend_services=>get_sapgui_workdir
changing
sapworkdir = l_temp_dir
EXCEPTIONS
GET_SAPWORKDIR_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5.
if sy-subrc = 0.
call method cl_gui_cfw=>flush
exceptions
others = 1.
if sy-subrc = 0 and not l_temp_dir is initial.
l_dir_path = l_temp_dir.
endif.
endif.
reg,
Bert
‎2008 Aug 18 3:37 PM
Hi there.. you guys are great..
Thanx Ganesh.. I just wanted the FM 'IW_C_GET_SAPWORKDIR'. The downloading process I have is a background one..
Thanx Bert.. So dumb of me not noticing the method in the class cl_gui_frontend_services. I am a novice in using the classes and the methods..
Thanx and regards
Kan