‎2007 Jun 11 3:49 PM
i need to get a file from application server folder with date validation.
how do i get the file from foder with fname, size and date.
‎2007 Jun 11 3:51 PM
‎2007 Jun 11 3:52 PM
‎2007 Jun 11 3:57 PM
i need to develop the interface based on input file, it will be placed on application server foder with different file names, so i need to read that folder and look for specific file *.txt copy into my ITAB.
‎2007 Jun 11 4:01 PM
This is Rich example ..... try this......
report zrich_0001 .
data: begin of itab occurs 0,
rec(1000) type c,
end of itab.
data: wa(1000) type c.
data: p_file type localfile.
data: ifile type table of salfldir with header line.
parameters: p_path type salfile-longname
default '/usr/sap/TST/DVEBMGS01/data/'.
call function 'RZL_READ_DIR_LOCAL'
exporting
name = p_path
tables
file_tbl = ifile
exceptions
argument_error = 1
not_found = 2
others = 3.
loop at ifile.
format hotspot on.
write:/ ifile-name.
hide ifile-name.
format hotspot off.
endloop.
at line-selection.
concatenate p_path ifile-name into p_file.
clear itab. refresh itab.
open dataset p_file for input in text mode.
if sy-subrc = 0.
do.
read dataset p_file into wa.
if sy-subrc <> 0.
exit.
endif.
itab-rec = wa.
append itab.
enddo.
endif.
close dataset p_file.
loop at itab.
write:/ itab.
endloop.
‎2007 Jun 11 4:03 PM
thanks, it doesn't have the date stamp.
how can i get one with fname, size & date
‎2007 Jun 11 4:12 PM
why don't try in SXDB Transaction ?
GOTO SXDB -> object 0010 -> enter -> click on copy ->here copy from and copy to
‎2007 Jun 11 4:04 PM
If the file is given as input in the selection screen u can use Dataset. (Open dataset). If there is no selection screen then the filename will be the same with te date and time stamp.
EX : Prgram name : ztest
file name : ztest_11062007_050311 (Program name _ date _time)
This will be the format so u can use dataset and u can build the filename in your program and use it.
Reward if helpful.
Regards,
Umasankar.
‎2007 Jun 11 4:09 PM
Hi,
Please try this.
DATA: FILETAB TYPE TABLE OF FILE_INFO,
FILEREC TYPE FILE_INFO,
COUNT TYPE i,
FZISE TYPE i.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
EXPORTING
DIRECTORY = '<Yourfilename>'
FILTER = ''
FILES_ONLY = 'X'
CHANGING
FILE_TABLE = FILETAB
COUNT = COUNT
EXCEPTIONS
CNTL_ERROR = 1
DIRECTORY_LIST_FILES_FAILED = 2
WRONG_PARAMETER = 3
ERROR_NO_GUI = 4
others = 5.
IF SY-SUBRC <> 0.
RAISE CNTL_ERROR.
ENDIF.
IF COUNT = 0.
* Does not exist
RESULT = ABAP_FALSE.
FSIZE = 0.
ELSE.
* Does exist
RESULT = ABAP_TRUE.
READ FILETAB INDEX 1 INTO FILEREC.
FSIZE = FILEREC-FILELENGTH.
ENDIF.
Regards,
Ferry Lianto