2006 Jan 24 4:16 PM
Hi,
Is there any FM or method to get all the files of a directory ( in the application server )if its path is given as input.
It should list the file name, creation date and also size.
Thanks,
Nawaz.
2006 Jan 24 4:20 PM
2006 Jan 24 4:22 PM
2006 Jan 24 8:41 PM
Hi,
you can use the follow code:
REPORT zdirtest.
DATA lv_dir TYPE rsmrgstr-path VALUE '/usr/sap/trans/data'.
DATA: wa_files TYPE rsfillst,
it_files LIKE TABLE OF wa_files.
START-OF-SELECTION.
CALL FUNCTION 'SUBST_GET_FILE_LIST'
EXPORTING
dirname = lv_dir
filenm = '*'
TABLES
file_list = it_files
EXCEPTIONS
access_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE /1 'Error! :-('.
ELSE.
LOOP AT it_files INTO wa_files.
WRITE: /1 wa_files-name,
wa_files-len.
ENDLOOP.
ENDIF.
However the field <b>MTIME</b> from the structure <b>RSFIILST</b> is not filled correctly with the number of seconds since 1970 because the field is defined to small.
So you can't list the correct modification date and time.
If you really need this, you should take a look in the Report <b>RSWATCH0</b> in the form <b>fill_file_list</b>.
This form fills an internal table with the correctly modification date and time.
Regards,
Stefan
2006 Jan 25 1:40 AM