2 Replies Latest reply on Dec 2, 2014 6:44 AM by Mark Francome

    Sending files via AFT in a specific sequence

    Mark Francome
      Share This:

      Hello,

      Slightly unusual request, we use AFT to file watch for locally created files on a Windows server. These files then have to be FTPed out to an external server. However the business user has this requirement - sometimes the files will be created in slightly the wrong order and they should be sorted so that they are transmitted according to sequnce number that is indicated in the file name (lowest should go first), i.e. -

       

      000027112014_000061132127.csv -> created at 11:26

      000027112014_000061132120.csv -> created at 11:27 = lowest sequence number, should go first.

      000027112014_000061132129.csv -> created at 11:28

       

      Luckily the file names are always in this standard, so I can use Control-M variables to save the file names and then get the sequence number via the SUBSTR function. However, is there any way (while keeping all this within the job definition) to send the lowest sequence number first (000027112014_000061132120.csv in the example above).

       

      My idea was to move the files into a folder and wait a few minutes before sending the files from there to the external site. I just don't know how to get the AFT to select them in a given sequence.

       

      Any ideas?

      Thanks,

      Mark.

        • 1. Re: Sending files via AFT in a specific sequence
          vikas jha

          Mark,

           

          What you may try doing is:

           

          1. Create a global variable

           

          2. In the job scheduling section go to More->Run Pre-Command and set the Global variable's value to the file you want to transfer using CTMVAR utility. Because your file names are following a standard and are always in incrementing sequence you should be able to construct your file name using control-m variables.

           

          3. Now Create the AFT job to transfer the file. Here give the directory name along with the Global variable. Which will make the full path of your file along with the file name.

           

          4. Once the file is transferred run the post command to set the global variable's value to GobalVariable+1. You may use Control-M system variables for addition.

           

          5. Run this file transfer job every minute.

           

          6. It will always transfer the file in sorted order based on your filename.

           

           

          I do not have environment to test it. So please test and let me know if there is any issue.

          1 of 1 people found this helpful
          • 2. Re: Re: Sending files via AFT in a specific sequence
            Mark Francome

            Hi Vikas,

             

            It turns out that the AFT will process the files in the name sequence (which is exactly what I want), i.e. if you do a 'dir' command then the AFT will process the files in the order as shown on the screen.

             

            I am saving the downloaded file name as an Autoedit variable and it turns out that the user wants the process paused while it is being processed on the remote server. Therefore I set up a file watcher to see when the file has gone from the "receiving" folder on the remote server (using the file name saved as the variable).

             

            So it's a simple solution but very effective!

             

            Thanks & Regards,

             

            Mark.