Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

getting files of a directory in app server

Former Member
0 Kudos
142

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.

4 REPLIES 4

Former Member
0 Kudos
93

Hi,

Try ARCHIVE_ADMIN_GET_FILE_INFO.

Regards.

Former Member
0 Kudos
93

Also try FM:

EPS_GET_FILE_ATTRIBUTES

Former Member
0 Kudos
93

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

former_member186741
Active Contributor
0 Kudos
93

try fm EPS_GET_DIRECTORY_LISTING