<?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: Process every file in a directory in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/process-every-file-in-a-directory/m-p/2998546#M708335</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ferry, that is beautiful!  I could give you a hug for that!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A quick follow up.  Can you move files and create directories in ABAP?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This would create the directory but what about moving/renaming a file?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;call function 'GUI_CREATE_DIRECTORY'
     exporting
dirname = '//&amp;lt;ip_address&amp;gt;/qfilesvr400/&amp;lt;host&amp;gt;/usr/sap/TST/SYS/Folder1'
     exceptions
          failed  = 1
          others  = 2.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Davis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Davis&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 30 Oct 2007 01:55:04 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-30T01:55:04Z</dc:date>
    <item>
      <title>Process every file in a directory</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/process-every-file-in-a-directory/m-p/2998544#M708333</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a way to "read" every file (csv) file in a directory on the server (a background job)?  I will never know the number of files on the server during any given run.  Is there a way to "loop" through a directory or bring the filenames into a table and loop through that table?  Basically I will have many csv files, each one being an order, and I will be processing these files (orders) each night.  I realize that I will need to use a dataset but how do I get to the files?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Davis&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2007 01:34:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/process-every-file-in-a-directory/m-p/2998544#M708333</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-30T01:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Process every file in a directory</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/process-every-file-in-a-directory/m-p/2998545#M708334</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;Please check this sample code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  ZDIRFILES.

PARAMETER: p_fdir type pfeflnamel DEFAULT '/usr/sap/tmp'.

data: begin of it_filedir occurs 10.
        include structure salfldir.
data: end of it_filedir.

START-OF-SELECTION.
* Get Current Directory Listing for OUT Dir
  call function 'RZL_READ_DIR_LOCAL'
    exporting
      name     = p_fdir
    tables
      file_tbl = it_filedir.

* List of files are contained within table it_filedir
  loop at it_filedir.
* Here you process the file individually
    write: / it_filedir-NAME.
    ...  

  endloop.

  ...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ferry Lianto&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2007 01:37:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/process-every-file-in-a-directory/m-p/2998545#M708334</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-30T01:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Process every file in a directory</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/process-every-file-in-a-directory/m-p/2998546#M708335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ferry, that is beautiful!  I could give you a hug for that!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A quick follow up.  Can you move files and create directories in ABAP?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This would create the directory but what about moving/renaming a file?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;call function 'GUI_CREATE_DIRECTORY'
     exporting
dirname = '//&amp;lt;ip_address&amp;gt;/qfilesvr400/&amp;lt;host&amp;gt;/usr/sap/TST/SYS/Folder1'
     exceptions
          failed  = 1
          others  = 2.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Davis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Davis&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2007 01:55:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/process-every-file-in-a-directory/m-p/2998546#M708335</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-30T01:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: Process every file in a directory</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/process-every-file-in-a-directory/m-p/2998547#M708336</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 can use SYSTEM command/function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: UNIX_COMMAND(500).

DATA: BEGIN OF ITAB OCCURS 0,
        LINE(255),
      END OF ITAB.
                                                                        
CONCATENATE 'mv' SOURCE_FILE DEST_FILE INTO UNIX_COMMAND
                                       SEPARATED BY SPACE.
                                                                        
CALL 'SYSTEM' ID 'COMMAND' FIELD COMMAND ID 'ITAB' FIELD TABM-*SYS*.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ferry Lianto&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2007 13:56:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/process-every-file-in-a-directory/m-p/2998547#M708336</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-30T13:56:12Z</dc:date>
    </item>
  </channel>
</rss>

