<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Function module to list files in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-list-files/m-p/2813832#M657897</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In Al11, there is a form 'fill_file_list' which does what you require (program: RSWATCH0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it has a statement&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    CALL 'C_DIR_READ_NEXT'
      ID 'TYPE'   FIELD file-type
      ID 'NAME'   FIELD file-name
      ID 'LEN'    FIELD file-len
      ID 'OWNER'  FIELD file-owner
      ID 'MTIME'  FIELD file-mtime
      ID 'MODE'   FIELD file-mode
      ID 'ERRNO'  FIELD file-errno
      ID 'ERRMSG' FIELD file-errmsg.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;which read everything&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;perhaps, you can call the same form fill_file_list in your program&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Sep 2007 06:34:39 GMT</pubDate>
    <dc:creator>former_member189059</dc:creator>
    <dc:date>2007-09-20T06:34:39Z</dc:date>
    <item>
      <title>Function module to list files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-list-files/m-p/2813830#M657895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hii&lt;/P&gt;&lt;P&gt;Can anyone help me in finding a function module that lists all the files form the application server directory along with the craetion date and time??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was using the function module SUBST_GET_FILE_NAME which lists all the files, but the date and time is not maintained here..I mean, the file creation date and time fields are available, but blank..I want the date and time as can be seen in AL11 when we browse for a file in a directory..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tx&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2007 06:10:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-list-files/m-p/2813830#M657895</guid>
      <dc:creator>abdulazeez12</dc:creator>
      <dc:date>2007-09-20T06:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Function module to list files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-list-files/m-p/2813831#M657896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One FM is RZL_READ_DIR  but it dont give file attributes.&lt;/P&gt;&lt;P&gt;You may also check these  -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RZL_READ_DIR                   Read directories of an application server&lt;/P&gt;&lt;P&gt;RZL_READ_DIR_GLOBAL            Read directories of an application server&lt;/P&gt;&lt;P&gt;RZL_READ_DIR_LOCAL             Read local directory&lt;/P&gt;&lt;P&gt;RZL_READ_DIR_REMOTE            Read Remote Directory&lt;/P&gt;&lt;P&gt;RZL_READ_DIR_REMOTE_SH         Read Directory: Cross Host Boundary via Remote OS Mechanism&lt;/P&gt;&lt;P&gt;RZL_READ_FILE                  Read file, cross host boundary via sap adm mechanim&lt;/P&gt;&lt;P&gt;RZL_READ_FILE_LOCAL            Read local file&lt;/P&gt;&lt;P&gt;RZL_READ_FILE_REMOTE           Read file&lt;/P&gt;&lt;P&gt;RZL_READ_FILE_REMOTE_SH        Read file, cross host boundary via remote-os-mechanism&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2007 06:15:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-list-files/m-p/2813831#M657896</guid>
      <dc:creator>amit_khare</dc:creator>
      <dc:date>2007-09-20T06:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: Function module to list files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-list-files/m-p/2813832#M657897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In Al11, there is a form 'fill_file_list' which does what you require (program: RSWATCH0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it has a statement&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    CALL 'C_DIR_READ_NEXT'
      ID 'TYPE'   FIELD file-type
      ID 'NAME'   FIELD file-name
      ID 'LEN'    FIELD file-len
      ID 'OWNER'  FIELD file-owner
      ID 'MTIME'  FIELD file-mtime
      ID 'MODE'   FIELD file-mode
      ID 'ERRNO'  FIELD file-errno
      ID 'ERRMSG' FIELD file-errmsg.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;which read everything&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;perhaps, you can call the same form fill_file_list in your program&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2007 06:34:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-list-files/m-p/2813832#M657897</guid>
      <dc:creator>former_member189059</dc:creator>
      <dc:date>2007-09-20T06:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Function module to list files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-list-files/m-p/2813833#M657898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi try using this &lt;/P&gt;&lt;P&gt;EPS_GET_DIRECTORY_LISTING      Get directory listing&lt;/P&gt;&lt;P&gt;EPS_GET_DIRECTORY_PATH         Get directory path for EPS subdirectories&lt;/P&gt;&lt;P&gt;EPS_GET_FILE_ATTRIBUTES&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please reward if useful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2007 06:37:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-list-files/m-p/2813833#M657898</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-20T06:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Function module to list files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-list-files/m-p/2813834#M657899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use this program or put the code in a function module if you want&lt;/P&gt;&lt;P&gt;i have not provided any output, so put a breakpoint at the write:/ 'end'. statement and see the contents of the file_list internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZKRIS_GET_DIRECTORY_FILES_ATTR
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*

REPORT  zkris_get_directory_files_attr.

PARAMETERS: p_dir(128) DEFAULT 'write your dir name here'.


TYPES: name_of_dir(1024)        TYPE c,
       name_of_file(260)        TYPE c,
       name_of_path(1285)       TYPE c.

DATA: BEGIN OF file,
        dirname     TYPE name_of_dir,  " name of directory. (possibly
                                       " truncated.)
        name        TYPE name_of_file, " name of entry. (possibly
                                       " truncated.)
        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 modification date, seconds since 1970
        mode(9)     TYPE c, " like "rwx-r-x--x": protection 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: sap_yes(1)  VALUE 'X'
    , sap_no(1)   VALUE ' '
    , srt(1)      VALUE 'T'
    , no_cs       VALUE ' '            " no MUST_ContainString
    , all_gen     VALUE '*'    " generic filename shall select all
    , strlen      LIKE sy-fdpos
    .

DATA: BEGIN OF file_list OCCURS 100,
        dirname     TYPE name_of_dir,  " name of directory. (possibly
                                       " truncated.)
        name        TYPE name_of_file, " name of entry. (possibly
                                       " truncated.)
        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 modification date, seconds since 1970
        mode(9)     TYPE c, " like "rwx-r-x--x": protection 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_list.

DATA: BEGIN OF searchpoints OCCURS 10,
        dirname     TYPE name_of_dir,  " name of directory.
        sp_name     TYPE name_of_file, " name of entry. (may end with *)
        sp_cs(10)   TYPE c, " ContainsString pattern for name.
      END OF searchpoints.


searchpoints-dirname = p_dir.
searchpoints-sp_name = '*'.
searchpoints-sp_cs = ''.

PERFORM fill_file_list USING searchpoints-dirname
                             searchpoints-sp_name
                             searchpoints-sp_cs
                             .

WRITE:/ 'end'.


*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  fill_file_list
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;A_DIR_NAME      text
*      --&amp;gt;A_GENERIC_NAME  text
*      --&amp;gt;A_MUST_CS       text
*----------------------------------------------------------------------*
FORM fill_file_list USING a_dir_name a_generic_name a_must_cs.
  " Routine von M. Mittelstein
******************************************************************CAS***
* Es wird eine Liste von Dateinamen in die Tabelle FILE_LIST gelesen.
*
* A_DIR_NAME ....... directory name
* A_GENERIC_NAME ... generic filename (may end with *)
* A_MUST_CS ........ a contains pattern for legal filenames  OR NO_CS
*

  DATA: errcnt(2) TYPE p VALUE 0.

*  call 'C_DIR_READ_FINISH'             " just to be sure
*      id 'ERRNO'  field file_list-errno
*      id 'ERRMSG' field file_list-errmsg.
*
*  call 'C_DIR_READ_START' id 'DIR'    field a_dir_name
*                          id 'FILE'   field a_generic_name
*                          id 'ERRNO'  field file-errno
*                          id 'ERRMSG' field file-errmsg.
  IF sy-subrc &amp;lt;&amp;gt; 0.
    sy-subrc = 4.
    EXIT.
  ENDIF.

  DO.
    CLEAR file.
    CALL 'C_DIR_READ_NEXT'
      ID 'TYPE'   FIELD file-type
      ID 'NAME'   FIELD file-name
      ID 'LEN'    FIELD file-len
      ID 'OWNER'  FIELD file-owner
      ID 'MTIME'  FIELD file-mtime
      ID 'MODE'   FIELD file-mode
      ID 'ERRNO'  FIELD file-errno
      ID 'ERRMSG' FIELD file-errmsg.
    file-dirname = a_dir_name.
    MOVE sy-subrc TO file-subrc.
    CASE sy-subrc.
      WHEN 0.
        CLEAR: file-errno, file-errmsg.
        CASE file-type(1).
          WHEN 'F'.                 " normal file.
            PERFORM filename_useable USING file-name file-useable.
          WHEN 'f'.                 " normal file.
            PERFORM filename_useable USING file-name file-useable.
          WHEN OTHERS.              " directory, device, fifo, socket,...
            MOVE sap_no  TO file-useable.
        ENDCASE.
        IF file-len = 0.
          MOVE sap_no TO file-useable.
        ENDIF.
      WHEN 1.                     " end of directory
        EXIT.
      WHEN 4.                     " filename too long
        MOVE sap_no TO file-useable.
      WHEN OTHERS.
        ADD 1 TO errcnt.
        IF errcnt &amp;gt; 90.
          EXIT.
        ENDIF.
        IF sy-subrc = 5.
          MOVE: '???' TO file-type,
                '???' TO file-owner,
                '???' TO file-mode.
        ELSE.
*         ULINE.
*         WRITE: / 'C_DIR_READ_NEXT', 'SUBRC', SY-SUBRC.
        ENDIF.
        MOVE sap_no TO file-useable.
    ENDCASE.
    PERFORM p6_to_date_time_tz(rstr0400) USING file-mtime
                                               file-mod_time
                                               file-mod_date.
*   * Does the filename contains the requested pattern?
*   * Then store it, else forget it.
    IF a_must_cs = no_cs.
      MOVE-CORRESPONDING file TO file_list.
      APPEND file_list.
    ELSE.
      IF file-name CS a_must_cs.
        MOVE-CORRESPONDING file TO file_list.
        APPEND file_list.
      ENDIF.
    ENDIF.
  ENDDO.

  CALL 'C_DIR_READ_FINISH'
      ID 'ERRNO'  FIELD file_list-errno
      ID 'ERRMSG' FIELD file_list-errmsg.
  IF sy-subrc &amp;lt;&amp;gt; 0.
    WRITE: / 'C_DIR_READ_FINISH', 'SUBRC', sy-subrc.
  ENDIF.
  IF srt = 'T'.
    SORT file_list BY mtime DESCENDING name ASCENDING.
  ELSE.
    SORT file_list BY name ASCENDING mtime DESCENDING.
  ENDIF.

  sy-subrc = 0.

ENDFORM.                    "FILL_FILE_LIST



*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  filename_useable
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;A_NAME     text
*      --&amp;gt;A_USEABLE  text
*----------------------------------------------------------------------*
FORM filename_useable USING a_name a_useable.
*----================------------------------
  DATA l_name(75).

  l_name = a_name.
  IF l_name(4) = 'core'.
    a_useable = sap_no.
  ELSE.
    a_useable = sap_yes.
  ENDIF.
ENDFORM.                    "FILENAME_USEABLE&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2007 07:01:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-list-files/m-p/2813834#M657899</guid>
      <dc:creator>former_member189059</dc:creator>
      <dc:date>2007-09-20T07:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: Function module to list files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-list-files/m-p/2813835#M657900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perfect &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 19:18:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-list-files/m-p/2813835#M657900</guid>
      <dc:creator>jcutinho</dc:creator>
      <dc:date>2015-04-10T19:18:37Z</dc:date>
    </item>
  </channel>
</rss>

