2 Replies Latest reply on Jan 14, 2021 12:52 AM by Nico Heinze

    Generate a target flat file with dynamic name and copy generated file to another directory

    Abhinav Verma New Member

      Background:

      I have a simple workflow which generates a flat file from a database table. I want to pick the file prefix and the destination locations from the parameter file, so that it can be changed later.

       

      Requirement:

      Generate the flat file with a specific name (ABC_YYYYMMDD.txt) to two locations (one is FTP location and other is archive). I am reading the directories from the workflow parameter file by defining the below workflow variables.

       

      Parameter File Contents:

      $OutputFileName=ABC_

      $$wf_DestLoc=\\Dir1\TgtFiles

      $$wf_ArchLoc=\\Dir2\ArchiveFiles

       

      I have figured out the creating the dynamic file name and creating the file in location 1 as shown in the screenshot below.

       

      For copying the file from the one location to another, I am using the below post session success command.

       

      cp $$wf_DestLoc\$OutputFileName$$wf_Timestamp.txt $$wf_ArchLoc\$OutputFileName$$wf_Timestamp.txt

       

      The session generates the file in $$wf_DestLoc location and the then gets hung. Relevant session Log below:

       

       

      If the copy is successful, then I would need to pass the variables to another mapping inside the workflow to store the filename, destination location and archive location in an audit table. The table values would be dependent on the values in the parameter file which could change at a later stage and hence, I want to avoid hard coding as much as possible.

       

      Any help/suggestions would be appreciated. If the requirement isn't clear, please comment and I will try my best to explain further. Thanks!