![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| ||||
| ||||
|
|
Hi there, I have a parent DTS that calls a child DTS through ActiveX scripts. Both of them have the same global variables defined in them. I need to call the |
|
Thanks, Andreas ************************************************** ************************** |
|
' ActiveX in Parent DTS Option Explicit Function Main Dim OriginalDate Dim TargetDate Dim InputFile Dim OutputFolder Dim TotalMonths Dim CurrDate Dim counter Dim fso Dim pkg Dim conTextFile Dim stpEnterLoop Dim stpFinished Dim oPkg, oStep Dim sServer, sUID, sPwd, iSecurity, sPkgPwd, sPkgName, sErrMsg Set oPkg = CreateObject("DTS.Package") sServer = "(local)" sUID = "" sPwd = "" iSecurity = DTSSQLStgFlag_UseTrustedConnection sPkgPwd = "" sPkgName = "StaticPoolJUNKCHILD" ' Load Child Package oPkg.LoadFromSQLServer sServer, sUID, sPWD, iSecurity , sPkgPWD, "", "", sPkgName Set pkg = DTSGlobalVariables.Parent Set fso = CreateObject("Scripting.FileSystemObject") OriginalDate = DTSGlobalVariables("OriginalDate").Value TargetDate = DTSGlobalVariables("TargetDate").Value OutputFolder = DTSGlobalVariables("OutputFolder").Value InputFile = DTSGlobalVariables("InputFile").Value TotalMonths = DateDiff("m", OriginalDate, TargetDate) counter = 0 While counter < TotalMonths ' Change OriginalDate in child package to the one calculated in parent package oPkg.GlobalVariables("OriginalDate").Value = DTSGlobalVariables("OriginalDate").Value ' Execute the child package oPkg.Execute CurrDate = DateAdd("m", counter, DateAdd("d", 1, OriginalDate)) - 1 DTSGlobalVariables("OriginalDate").Value = CurrDate msgbox "Parent DTS - counter: " & counter & ", CurrentDate: " & CurrDate counter = counter + 1 Wend Main = DTSTaskExecResult_Success End Function ************************************************** ************************** |
|
' ActiveX in Child DTS Dim oFSO Dim sDate Dim oDate Dim tDate Dim fName Dim fTemp Dim fDir Dim fSourceFile Dim fDestFile Function Main() fTemp = DTSGlobalVariables("InputFile").value fName = Left(fTemp, Len(fTemp) - 4) sDate = DTSGlobalVariables("OriginalDate").value oDate = Month(sDate) & "-" & Day(sDate) & "-" & Year(sDate) sDate = DTSGlobalVariables("TargetDate").value tDate = Month(sDate) & "-" & Day(sDate) & "-" & Year(sDate) fDir = DTSGlobalVariables("OutputFolder").value & "\" fSourceFile = fDir & fName & ".xls" fDestFile = fDir & "Archive\" & fName & " " & oDate & " to " & tDate & ".xls" msgbox "Child DTS - InputFile: " & fTemp & ", OriginalDate: " & DTSGlobalVariables("OriginalDate").value & ", DestFile: " & fDestFile DTSGlobalVariables("OutputFile").value = fDestFile Main = DTSTaskExecResult_Success End Function |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Darren, Thanks for the response. I only need OriginalDate changed by the parent package. The child package runs fine by itself without errors. The parent package runs fine as well, but the problem is that the new OriginalDate specified in the parent package doesn't get passed to the child package. If you specify different values for the OriginalDate in the two packages, you'll see that the one for the parent package doesn't get passed to the child package and the child package uses its own. You could create two different text files on your local drive that have the structure below and use those in the DTS packages tested, if you have the time. The DTS packages can have just a Dynamic Properties Task and an ActiveX script. Any input would be greatly appreciated. Thanks again, Andreas *********************************************** The file below is called: "SP Dates.ini" and is used in one of the DTS packages. The OriginalDate can be changed and saved under the same name in a different subdirectory and used in the other DTS package. ----------------------- [Static Pool] OriginalDate="12-31-2003" TargetDate="02-29-2004" OutputFolder="\\oomc.root\user\Andreas.Terzis\Docs \Computing\Software\Re ports\Output\Option One\Static Pool" InputFile="Static Pool Results.xls" *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
Darren, Thanks for the response. The child package is executed by itself sometimes by a job and runs let's say for the last month. Sometimes though, I need to have a job run which calls the parent package, which in turn calls the child package. The child package has all the logic for my report and the parent package only changes the OriginalDate and then executes the child package in a loop. Let's say that the child package uses an OriginalDate of '01-31-04' (and a TargetDate of '02-29-04'). When it is executed by itself (not called by the parent package), it gets data between those two dates. But I need to have the child package generate 13 reports sometimes, for trending purposes. The TargetDate always remains the same but the OriginalDate should be '01-31-03' in the first execution, '02-28-03' in the second and so on, up to '01-31-04'. That's why I need those OriginalDate instances change every time in the parent package. I guess I can eliminate the parent package text input file, but I am not sure if the user would want the historical data generated for 13 months or 25 or 6. Does that make sense? I am glad you got your example to work. I still cannot get mine to work. Is there any way you could e-mail me the two packages (if they still work after my latest explanation)? Basically, the OriginalDate in the child package should change each time the package is called by the parent package. That should be printed every time by the "msgbox" command (msgbox "ChildDTS - ..."). I would appreciate your help. Thanks, Andreas |
#7
| |||
| |||
|
#8
| ||||||||
| ||||||||
|
|
Hi there, I have a parent DTS that calls a child DTS through ActiveX scripts. Both |
|
Thanks, Andreas ************************************************** ********************** |
|
' ActiveX in Parent DTS Option Explicit Function Main Dim OriginalDate Dim TargetDate Dim InputFile Dim OutputFolder Dim TotalMonths Dim CurrDate Dim counter Dim fso Dim pkg Dim conTextFile Dim stpEnterLoop Dim stpFinished Dim oPkg, oStep Dim sServer, sUID, sPwd, iSecurity, sPkgPwd, sPkgName, sErrMsg Set oPkg = CreateObject("DTS.Package") sServer = "(local)" sUID = "" sPwd = "" iSecurity = DTSSQLStgFlag_UseTrustedConnection sPkgPwd = "" sPkgName = "StaticPoolJUNKCHILD" ' Load Child Package oPkg.LoadFromSQLServer sServer, sUID, sPWD, iSecurity , sPkgPWD, "", "", |
|
Set pkg = DTSGlobalVariables.Parent Set fso = CreateObject("Scripting.FileSystemObject") OriginalDate = DTSGlobalVariables("OriginalDate").Value TargetDate = DTSGlobalVariables("TargetDate").Value OutputFolder = DTSGlobalVariables("OutputFolder").Value InputFile = DTSGlobalVariables("InputFile").Value TotalMonths = DateDiff("m", OriginalDate, TargetDate) counter = 0 While counter < TotalMonths ' Change OriginalDate in child package to the one calculated in parent package oPkg.GlobalVariables("OriginalDate").Value = DTSGlobalVariables("OriginalDate").Value ' Execute the child package oPkg.Execute CurrDate = DateAdd("m", counter, DateAdd("d", 1, OriginalDate)) - 1 DTSGlobalVariables("OriginalDate").Value = CurrDate msgbox "Parent DTS - counter: " & counter & ", CurrentDate: " & CurrDate counter = counter + 1 Wend Main = DTSTaskExecResult_Success End Function ************************************************** ********************** |
|
' ActiveX in Child DTS Dim oFSO Dim sDate Dim oDate Dim tDate Dim fName Dim fTemp Dim fDir Dim fSourceFile Dim fDestFile Function Main() fTemp = DTSGlobalVariables("InputFile").value fName = Left(fTemp, Len(fTemp) - 4) sDate = DTSGlobalVariables("OriginalDate").value oDate = Month(sDate) & "-" & Day(sDate) & "-" & Year(sDate) sDate = DTSGlobalVariables("TargetDate").value tDate = Month(sDate) & "-" & Day(sDate) & "-" & Year(sDate) fDir = DTSGlobalVariables("OutputFolder").value & "\" fSourceFile = fDir & fName & ".xls" fDestFile = fDir & "Archive\" & fName & " " & oDate & " to " & tDate & |
|
msgbox "Child DTS - InputFile: " & fTemp & ", OriginalDate: " & DTSGlobalVariables("OriginalDate").value & ", DestFile: " & fDestFile DTSGlobalVariables("OutputFile").value = fDestFile Main = DTSTaskExecResult_Success End Function |
|
Darren, Thanks for the response. I only need OriginalDate changed by the parent package. The child package runs fine by itself without errors. The parent package runs fine as well, but the problem is that the new OriginalDate specified in the parent package doesn't get passed to the child package. If you specify different values for the OriginalDate in the two packages, you'll see that the one for the parent package doesn't get passed to the child package and the child package uses its own. You could create two different text files on your local drive that have the structure below and use those in the DTS packages tested, if you have the time. The DTS packages can have just a Dynamic Properties Task and an ActiveX script. Any input would be greatly appreciated. Thanks again, Andreas *********************************************** The file below is called: "SP Dates.ini" and is used in one of the DTS packages. The OriginalDate can be changed and saved under the same name in a different subdirectory and used in the other DTS package. ----------------------- [Static Pool] OriginalDate="12-31-2003" TargetDate="02-29-2004" OutputFolder="\\oomc.root\user\Andreas.Terzis\Docs \Computing\Software\Re ports\Output\Option One\Static Pool" InputFile="Static Pool Results.xls" *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
|
Darren, Thanks for the response. The child package is executed by itself sometimes by a job and runs let's say for the last month. Sometimes though, I need to have a job run which calls the parent package, which in turn calls the child package. The child package has all the logic for my report and the parent package only changes the OriginalDate and then executes the child package in a loop. Let's say that the child package uses an OriginalDate of '01-31-04' (and a TargetDate of '02-29-04'). When it is executed by itself (not called by the parent package), it gets data between those two dates. But I need to have the child package generate 13 reports sometimes, for trending purposes. The TargetDate always remains the same but the OriginalDate should be '01-31-03' in the first execution, '02-28-03' in the second and so on, up to '01-31-04'. That's why I need those OriginalDate instances change every time in the parent package. I guess I can eliminate the parent package text input file, but I am not sure if the user would want the historical data generated for 13 months or 25 or 6. Does that make sense? I am glad you got your example to work. I still cannot get mine to work. Is there any way you could e-mail me the two packages (if they still work after my latest explanation)? Basically, the OriginalDate in the child package should change each time the package is called by the parent package. That should be printed every time by the "msgbox" command (msgbox "ChildDTS - ..."). I would appreciate your help. Thanks, Andreas |
![]() |
| Thread Tools | |
| Display Modes | |
| |