Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 String Concatenation in DTS

Author  Topic 

Donovan
Starting Member

8 Posts

Posted - 2004-05-12 : 15:12:02
I have a file that gets placed on our ftp site once a week. The file is named achconxx.dat

The xx is the fiscal week meaning the file one week looks like achcons18.dat and the next week it will look like achcons19.dat

I am trying use an ActiveX script in my DTS package to move and unzip that file and rename to achcons.dat so I can import.

My code looks like this so far:

Function Main()

Dim objWshshell, objFso
Dim strCmd, strSubject, strMessage, strFileattachment, rc

DTSGlobalVariables("gv_strWklydir").value = "\\E$\Update\Data\" ' Weekly directory
DTSGlobalVariables("gv_strACHFile").value = "achcon" & DTSGlobalVariables("gv_strFW").value & ".zip" ' ACH Group weekly file

Set objFso = CreateObject("Scripting.FileSystemObject")
Set objWshshell = CreateObject("WScript.Shell")
rc = 0

' Build the Winzip command

If (objFso.FileExists(DTSGlobalVariables("gv_strWklydir").value & DTSGlobalVariables("gv_strACHFile").value)) Then

strCmd = "winzip32.exe -e -o " & DTSGlobalVariables("gv_strWklydir").value &_
DTSGlobalVariables("gv_strACHFile") & " " & DTSGlobalVariables("gv_strWklydir").value

rc = objWshshell.Run(strCmd, 1, true)

' Rename file

If (objFso.FileExists(DTSGlobalVariables("gv_strWklydir").value & objFso.GetBaseName(DTSGlobalVariables("gv_strACHFile")) & ".dat")) Then
objFso.GetFile(DTSGlobalVariables("gv_strWklydir").value & objFso.GetBaseName(DTSGlobalVariables("gv_strACHFile")) & ".dat").Copy (DTSGlobalVariables("gv_strWklydir").value & "achcon.dat")
End If

Set objWshshell = Nothing
Set objFso = Nothing
End If

I think my concatenation is missing something due to to "gv_strFW" being numeric. I also have an e-mail routine that sends me an e-mail if the file doesn't exist. The e-mail works so my routine can't see the file it needs to move/unzip and rename.

Any help is appreciated.
   

- Advertisement -