<?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: Read dynamic file name in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-dynamic-file-name/m-p/8334861#M1638516</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;You need to scan the path in order to get all files stored and then to read it;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the fm EPS_GET_DIRECTORY_LISTING in order to scan the directory:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: dir_name  LIKE  epsf-epsdirnam,
      file_mask LIKE  epsf-epsfilnam.
DATA: filename  TYPE string.
DATA: t_dir_list TYPE STANDARD TABLE OF epsfili WITH HEADER LINE.
dir_name  = '&amp;lt;application path name&amp;gt;'.
file_mask = '&amp;lt;static&amp;gt;*.*'.

CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
  EXPORTING
    dir_name               = dir_name
    file_mask              = file_mask
  TABLES
    dir_list               = t_dir_list
  EXCEPTIONS
    invalid_eps_subdir     = 1
    sapgparam_failed       = 2
    build_directory_failed = 3
    no_authorization       = 4
    read_directory_failed  = 5
    too_many_read_errors   = 6
    empty_directory_list   = 7
    OTHERS                 = 8.
IF sy-subrc &amp;lt;&amp;gt; 0.
ENDIF.

LOOP AT t_dir_list.
  CONCATENATE dir_name '/' t_dir_list-name INTO filename.
  OPEN DATASET filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
  .........
  CLOSE DATASET filename.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 27 Nov 2011 17:57:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-11-27T17:57:27Z</dc:date>
    <item>
      <title>Read dynamic file name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-dynamic-file-name/m-p/8334860#M1638515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to read a file from the application server with the file name "static""timestamp".txt, where static is the static file name and timestamp would be added at the end of the file name. Please suggest me a way to read all such files one by one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Nov 2011 17:41:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-dynamic-file-name/m-p/8334860#M1638515</guid>
      <dc:creator>former_member185846</dc:creator>
      <dc:date>2011-11-27T17:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Read dynamic file name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-dynamic-file-name/m-p/8334861#M1638516</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;You need to scan the path in order to get all files stored and then to read it;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the fm EPS_GET_DIRECTORY_LISTING in order to scan the directory:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: dir_name  LIKE  epsf-epsdirnam,
      file_mask LIKE  epsf-epsfilnam.
DATA: filename  TYPE string.
DATA: t_dir_list TYPE STANDARD TABLE OF epsfili WITH HEADER LINE.
dir_name  = '&amp;lt;application path name&amp;gt;'.
file_mask = '&amp;lt;static&amp;gt;*.*'.

CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
  EXPORTING
    dir_name               = dir_name
    file_mask              = file_mask
  TABLES
    dir_list               = t_dir_list
  EXCEPTIONS
    invalid_eps_subdir     = 1
    sapgparam_failed       = 2
    build_directory_failed = 3
    no_authorization       = 4
    read_directory_failed  = 5
    too_many_read_errors   = 6
    empty_directory_list   = 7
    OTHERS                 = 8.
IF sy-subrc &amp;lt;&amp;gt; 0.
ENDIF.

LOOP AT t_dir_list.
  CONCATENATE dir_name '/' t_dir_list-name INTO filename.
  OPEN DATASET filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
  .........
  CLOSE DATASET filename.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Nov 2011 17:57:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-dynamic-file-name/m-p/8334861#M1638516</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-27T17:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Read dynamic file name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-dynamic-file-name/m-p/8334862#M1638517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the prompt reply, Max. Is there a way  to delete the file once it is processed? Because, I want to read the file and delete it from the directory.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Nov 2011 18:35:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-dynamic-file-name/m-p/8334862#M1638517</guid>
      <dc:creator>former_member185846</dc:creator>
      <dc:date>2011-11-27T18:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Read dynamic file name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-dynamic-file-name/m-p/8334863#M1638518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes of course&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After reading it you need to use DELETE DATASET statament to delete the file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT t_dir_list.
  CONCATENATE dir_name '/' t_dir_list-name INTO filename.
  OPEN DATASET filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
  .........
  CLOSE DATASET filename.
  DELETE DATASET filename.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Nov 2011 22:45:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-dynamic-file-name/m-p/8334863#M1638518</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-27T22:45:17Z</dc:date>
    </item>
  </channel>
</rss>

