01-10-2008 5:25 PM
Hi All.
I need to get all filename, last changed date, last changed time in a directory. Is there any function module for this?
Regards,
Venkat.
01-10-2008 5:32 PM
Use this class/method, it will return the data you need.
data: idir_tab type standard table of file_info.
data: lv_directory type string.
data: count type i.
lv_directory = 'C:\'.
call method cl_gui_frontend_services=>directory_list_files
exporting
directory = lv_directory
files_only = 'X'
changing
file_table = idir_tab
count = count
exceptions
cntl_error = 1
directory_list_files_failed = 2
wrong_parameter = 3
error_no_gui = 4
others = 5.
Regards,
Rich Heilman
01-10-2008 8:34 PM
Rich,
I want to read directory from application server running with Linux os. When I use EPS_GET_DIRECTORY_LISTING FM with './' as filename the FM is returning all files but I give any directory like /tmp, /data (from AL11), its saying directory not found. Please let me know if you have an idea how to pass the directory name to the FM.
Regards,
Venkat.
01-10-2008 9:29 PM
01-10-2008 5:49 PM
hi,
if the directory is in any application server try to use this code
> DATA: wa_file TYPE zdpp_file_read.
> DATA: nomefile(75).
> DATA: ext_chek(3).
>DATA: BEGIN OF wa_file,
> dirname TYPE DIRNAME_AL11, " name of directory
> name TYPE FILENAME_AL11," name of entry
> type(10) TYPE c, " type of entry.
> len(8) TYPE p, " length in bytes.
> owner(8) TYPE c, " owner of the entry.
> mtime(6) TYPE p, " last mod.date, sec since 1970
> mode(9) TYPE c, " like "rwx-r-x--x": prot. mode
> useable(1) TYPE c,
> subrc(4) TYPE c,
> errno(3) TYPE c,
> errmsg(40) TYPE c,
> mod_date TYPE d,
> mod_time(8) TYPE c, " hh:mm:ss
> seen(1) TYPE c,
> changed(1) TYPE c,
> END OF file.
> data: files like wa_file occurs 0 with header line.
>
> CALL FUNCTION 'FILE_GET_NAME'
> EXPORTING
> client = sy-mandt
> logical_filename = logpath
> operating_system = sy-opsys
> IMPORTING
> file_name = path
> EXCEPTIONS
> file_not_found = 1
> OTHERS = 2.
> IF sy-subrc <> 0.
> RAISE file_not_found.
> ENDIF.
>
> DATA: last_path TYPE i.
> DO.
> last_path = strlen( path ).
> last_path = last_path - 1.
> IF pathlast_path(1) = '/' or pathlast_path(1) = '\'.
> EXIT.
> ELSE.
> CLEAR path+last_path(1).
> ENDIF.
> ENDDO.
>
> MOVE extension TO ext_chek.
> TRANSLATE ext_chek TO UPPER CASE.
> nomefile = '*'.
>
> CALL 'C_DIR_READ_FINISH'
> ID 'ERRNO' FIELD wa_file-errno
> ID 'ERRMSG' FIELD wa_file-errmsg.
>
> CALL 'C_DIR_READ_START' ID 'DIR' FIELD path
> ID 'FILE' FIELD nomefile
> ID 'ERRNO' FIELD wa_file-errno
> ID 'ERRMSG' FIELD wa_file-errmsg.
> IF sy-subrc <> 0.
> RAISE wrong_directory.
> ELSE.
>
> DO.
> CLEAR wa_file.
>
> CALL 'C_DIR_READ_NEXT'
> ID 'TYPE' FIELD wa_file-type
> ID 'NAME' FIELD wa_file-name
> ID 'MTIME' FIELD wa_file-mtime
> ID 'ERRNO' FIELD wa_file-errno
> ID 'ERRMSG' FIELD wa_file-errmsg.
> IF sy-subrc <> 0.
> EXIT.
> ENDIF.
>
> PERFORM p6_to_date_time_tz(rstr0400) USING wa_file-mtime
> wa_file-mod_time
> wa_file-mod_date.
> MOVE path TO wa_file-dirname.
> APPEND wa_file TO files.
> ENDDO.
> ENDIF.
>
> CALL 'C_DIR_READ_FINISH'
> ID 'ERRNO' FIELD wa_file-errno
> ID 'ERRMSG' FIELD wa_file-errmsg.
bye,
marco