05-09-2007 9:16 AM
hi all,
my requirement is to check given file path while downloading a report into flat file is correct or not. i.e if file path is wrong then an error message should be given otherwise the report should be downloaded.how to do this.
with regards,
suresh babu aluri.
05-09-2007 9:20 AM
Instead of validating path , u can give F4 help for that
PARAMETERS:p_file LIKE rlgrap-filename.
data : v_file type string.
*Input Help for the Download Directory
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = v_repid
dynpro_number = syst-dynnr
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
v_filename = p_file.
05-09-2007 9:19 AM
Hi
is there a pre-defined folder or location where you have to download the report to,
then you can compare using the string.
regards,
Raghavendra
05-09-2007 9:20 AM
Instead of validating path , u can give F4 help for that
PARAMETERS:p_file LIKE rlgrap-filename.
data : v_file type string.
*Input Help for the Download Directory
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = v_repid
dynpro_number = syst-dynnr
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
v_filename = p_file.
05-09-2007 9:22 AM
<b>To download in desktop</b>
DATA: l_ofile1 TYPE string.
CLEAR: l_ofile1.
l_ofile1 = p_ofile_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = l_ofile1
filetype = 'ASC'
TABLES
data_tab = p_local_table
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 EQ 19.
MESSAGE e000 WITH 'File Not Found'.
ENDIF.
ENDIF.
05-09-2007 9:23 AM
<b>For application server</b>* Audit file download in application server
OPEN DATASET p_ofile_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
CLEAR: wa_local.
LOOP AT p_local_table INTO wa_local.
TRANSFER wa_local TO p_ofile_file.
CLEAR: wa_local.
ENDLOOP.
CLOSE DATASET p_ofile_file.
ELSE.
MESSAGE e000 WITH 'File Not Found'.
ENDIF.
05-09-2007 9:35 AM
Hi Sureshbabu,
<b> FM 'gui_download' is having exception regarding this .
FILE NOT FOUND.</b> check exception 19 in FM
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = v_file
filetype = 'ASC'
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 = '30'
IMPORTING
FILELENGTH =
TABLES
data_tab = i_tab
FIELDNAMES =
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
<b> FILE_NOT_FOUND = 19</b>
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
.
IF sy-subrc <> 0.
message e001 " e001 - file not found.
ENDIF.
Reward points if helpful.
Regards,
Hemant