Share via


Scripting the Report Preparation DTS Task

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

The following script creates and runs the Report Preparation DTS task. You can use this script in two ways to create a package that contains the DTS task to run:

  • You can run the package on the command line by using the command DTSRun.exe. The file DTSRun.exe is automatically installed on your server when you install SQL Server.

  • You can copy the script into a Visual Basic script (.vbs) file and run it by using CScript as follows:

    [drive]:cscriptfilename.vbs

For a description of the Report Preparation DTS task, see Commerce Server DTS Tasks.

Note

Run the Report Preparation task after all the data for all the Web sites that share the Data Warehouse has been imported into the Data Warehouse. Do not run the Report Preparation DTS task separately for each Web site in the Data Warehouse.

'*********************************************************************
' Report Preparation DTS Task
' This script creates a DTS package and runs it.
'**********************************************************************
Dim oPackage As DTS.Package
Dim oTask As DTS.Task
Dim oStep As DTS.Step
Dim oTaskProps As Object

'******************************************************************
' Define package properties.
'******************************************************************
Set oPackage = CreateObject("DTS.Package")
oPackage.FailOnError = True 
oPackage.Name = "Report Preparation DTS Task"
oPackage.Description = "Populates OLAP cubes with the import data, prepares the data for report generation, and refreshes the cubes after a deletion."

'******************************************************************
' Create a task.
'******************************************************************
'Make sure that you are passing the correct ProgID.
Set oTask = oPackage.Tasks.New("Commerce.DTSPostImport")
oTask.Name = "Task1"
oTask.Description = "Creates a task for PrepareRport DTS"
Set oTaskProps = oTask.Properties

oTaskProps("SourceName").Value = "DataWarehouse 1"
' Set the processing type to 1 for full import, 2 for refresh, 
' or 100 for incremental import.
oTaskProps("ProcessingType").Value = 1
oTaskProps("TaskName").Value = "Task1"
oTaskProps("NumRetries").Value = 1
oTaskProps("RetryInterval").Value = 30

oPackage.Tasks.Add oTask

'******************************************************************
' Create a step.
'******************************************************************
Set oStep = oPackage.Steps.New
oStep.Name = "Step1"
oStep.TaskName = "Task1"

oStep.ExecuteInMainThread = True
oPackage.Steps.Add oStep

'******************************************************************
' Execute the package.
'******************************************************************
oPackage.Execute

    For I = 1 To oPackage.Steps.Count
        If oPackage.Steps(I).ExecutionResult = 1 Then
            iStatus = False
            MsgBox oPackage.Steps(I).Name + " in the " + _
            oPackage.Name + " failed."
        End If
    Next 

MsgBox oPackage.Name + " Done"

Set oStep = Nothing
Set oTaskProps = Nothing
Set oProps = Nothing
Set oTaskProps = Nothing
Set oPackage = Nothing

See Also

Other Resources

DTSPostImport Object

Commerce Server DTS Tasks

Scripting DTS Tasks