Hello all,
I have been thrown to the wolves at my new job because the guy that was training me left abruptly. I am trying to figue out a DTS package and automate a task. A file gets placed on our ftp site once a week. The name of this file will change every week. The first part is achcon_ and the second part is fwxx with the xx being the fiscal week of the year, as in achcon_fw19 or achcon_fw20. I am trying to grab that file on our ftp site and move it to a working directory. Can't seem to get it to work. I have an e-mail after this code to notify me of a failure and that has been working.
I think my error is in concatenating the two strings.
Any help is apprieciated.
Code:
Function Main()
Dim objFso 'File system object
Set objFso = CreateObject("Scripting.FileSystemObject")
DTSGlobalVariables("gv_strWklydir").value = "\\Database\WeeklyFiles\ACH\" ' Weekly directory
DTSGlobalVariables("gv_strFTPDir").value = "\\Jax\D$\ClientFTP\GE\" ' FTP directory where ACH file gets uploaded
DTSGlobalVariables("gv_strACHFile").value = "achcon_" & DTSGlobalVariables("gv_strFW").value & ".zip" ' ACH weekly file
' If the old update file exists, delete it. This should never happen but just in case...
If (objFso.FileExists(DTSGlobalVariables("gv_strWklydir").value & DTSGlobalVariables("gv_strACHFile").value)) Then
objFso.GetFile(DTSGlobalVariables("gv_strWklydir").value & DTSGlobalVariables("gv_strACHFile").value).Delete
End If
' Move the new ACH Group file to the weekly directory.
If (objFso.FileExists(DTSGlobalVariables("gv_strFTPDir").value & DTSGlobalVariables("gv_strACHFile").value & DTSGlobalVariables("gv_strFW").value)) Then
objFso.GetFile(DTSGlobalVariables("gv_strFTPDir").value & DTSGlobalVariables("gv_strACHFile").value).Move (DTSGlobalVariables("gv_strWklydir").value & DTSGlobalVariables("gv_strACHFile").value)
Else
' Email that the moving of the ACH file failed and exit the task,
' reporting a failure.
strSubject = "GE Database - The moving of the ACH Group file failed."
strMessage = "Hello DBAdmins," & vbCrLf & vbCrLf & "The moving of the ACH Group file " &_
DTSGlobalVariables("gv_strFW") & " failed. Wassup?" & vbCrLf & vbCrLf & "Server"
FrmtEmail strSubject, strMessage, strFileattachment
Main = DTSTaskExecResult_Failure
Exit Function
End If
Main = DTSTaskExecResult_Success
Set objFso = Nothing
End Function