October 23, 2003 at 10:49 am
i need to load a series of text files that are ftp'd from the mainframe. i know the file names i should receive. they may not be the same ones everyday and i have no control of the order or timing of the mainframe ftping them to the server. how can i write a task to wait until all of the expected files have been received before the next step begins? i was able to do it for just one file but have no clue as to how to do it for more than one. thanks!
October 24, 2003 at 7:28 am
Here is some vb script that looks at the file attributes. The DTS can then dynamically see if the file is new. A suggestion is to create a global variable that would pass the file names to your import DTS. (Just a thought I did it and its cool as you limit the # DTS's)
'**********************************************************************
' Input file checker
'-------------------------------
' This script checks if the file on the server is the right one to
' import for a daily run '
' It uses the file attribute(size) to determine if the filesize is 0
' which implies that the file is a mess.
'
' Task will replace messy files '
'************************************************************************
Option Explicit
Function Main()
On Error Resume Next
Dim oPackage, oConn, SourceFileName,DummyFileName, FileSystem, CnData, datMod, _
OldFile, NewFile, Filename1
Main = DTSTaskExecResult_Success
set oPackage = DTSGlobalVariables.parent
'*************************************************************************
'Add connection name or id here
'----------------------------------------------
set oConn = oPackage.connections("Text File (Source)")
'*************************************************************************
CnData = oConn.DataSource
Set FileSystem = CreateObject("Scripting.FileSystemObject")
Filename1 = CnData
'Get the file to start working with it
Set SourceFileName = FileSystem.GetFile(Filename1)
DummyFileName = Filename1 & ".dummy"
If CDbl(SourceFileName.Size) = 0 Then
FileSystem.DeleteFile Filename1
FileSystem.MoveFile Filename1 & ".dummy", Filename1
FileSystem.CopyFile Filename1, Filename1 & ".dummy"
DTSTaskExecResult_Success
End If
Set FileSystem = Nothing
Set oPackage = Nothing
Set oConn = Nothing
Set Filename1 = Nothing
Set SourceFileName = Nothing
Set m1 = Nothing
Set z1 = Nothing
End Function
If it aint broke don't fix it!
Andy.
October 24, 2003 at 2:41 pm
thanks for the help. i tried to get your example to work but honestly i do not know enough about vbscript to get it to work properly. i ended up doing it another way. if you are interested i can show you. thanks again!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply