0 Replies Latest reply on Feb 2, 2012 11:54 AM by user373742 - oracle

    Copy & rename ident. file to new Loc&Cat in OpenBatch folder - dynamic

    user373742 - oracle
      I am in the process of writing an Event script to deal with the folllowing situation:

      During an automated upstream process certain files are dumped, prenamed (per naming convension) into the OpenBatch folder ready for standard batch upload the next morning.

      The Event Script is designed to check if any of the qued files meet certain Loc, Cat & Per criteria, and if any file matches the criteria it should be copied to the end of the same OpenBatch file que, and then renamed to a different predetermined Loc, Cat & Per. This is based on a standard serial batch load setup.

      I have chosen to acvtivate this process after each file reaches the AftLoad event, where the strLoc, strCat & strPer information is already captured in the AftLoad arguments.

      Here is my script:

      ----------------------------------------------------------------------------------------------------------
      Sub AftLoad(strLoc, strCat, strPer, strTCat, strTPer, strFile)
      ‘------------------------------------------------------------------
      ‘ FDM EVENT Script:
      ‘Purpose: This script creates a copy of a specific file and
      ‘ then renames it according to predetermined criteria.
      ‘------------------------------------------------------------------
      ‘Declare local variables
           Dim fso
           Dim strPath
           Dim iFleCnt
           Dim fld
           Dim fle
           Dim strAlpha

      ‘Declare file system object
           Set fso = CreateObject("Scripting.FileSystemObject")

      ‘Count the number of files in the folder
           strPath = "C:\Hyperion\FDMData\Test\Inbox\Batches\OpenBatch"
           Set fld = fso.GetFolder(strPath)
           Set fle = fld.Files
           iFleCnt = fle.Count
           iFleCnt = iFleCnt + 1

      ‘Set the next character for the last file in the batch
           strAlpha = "abcdefghijklmnopqrstuvwxyz"
           strAlpha = MID(strAlpha,iFleCnt,1)

      ‘Destroy file system object
           Set fso=Nothing

      ‘Declare file system object
           Set fso = CreateObject("Scripting.FileSystemObject")

      ‘Test whether file meets duplication criteria
           If strLoc = "LOCATION1" And strCat = "SCEN1" Then

      ‘Then test if it is a YEND instance          
                If Left(strPer,3)="Jan" Then
                     
                     fso.CopyFile strPath & "\" & strFile , strPath & "\" & strAplha & "@LOCATION2@SCEN2@" & MID(RIGHT(strFile,17)1,11) & "RM.txt", False

      ‘...Or if it is a HALFYEND instance
                ElseIf Left(strPer,3)="Jul" Then

                     fso.CopyFile strPath & "\" & strFile , strPath & "\" & strAplha & "@LOCATION2@SCEN2@" & MID(RIGHT(strFile,17)1,11) & "RM.txt", False

                End If

           End If

      ‘Destroy file system object
           Set fso=Nothing

      End Sub

      ----------------------------------------------------------------------------------------------------------

      Have I done this right?

      Please let me know if I’ve missed anything…or fallen off the edge here in attempting this.

      Urgent feedback will be treated with devotion!

      Cheers

      R

      Edited by: 911307 on Feb 2, 2012 3:54 AM