IBM SPSS Collaboration and Deployment Services integration script examples
This section demonstrates a full-cycle example for integrating .dms and .mrs scripts in IBM SPSS Collaboration and Deployment Services job steps. The scenario uses a .dms script that transfers HDATA and uses the output data to generate a report through an .mrs script.
1: Exposing the .dms script parameters
'==============================================================
' Parameter Definition Help:
' 1. ?? - Input parameters definition
' 2. @@ - Output variables definition
' 3. $$ - Output files definition
'===========================================================================================
' <PARAM_NAME> <TYPE> <DEFAULT_VALUE> <DESCRIPTION>
'--------------------+--------+------------------------------+------------------------------
'?? SELECT_QUERY Text "SELECT * FROM HDATA.Person" "Select query string"
'@@ COMPLETION_CODE Long "0" "Job completion status code"
'$$ OUTPUT_METADATA MDD "\\server\share\person.mdd" "Output person metadata file"
'$$ OUTPUT_CASEDATA DDF "\\server\share\person.ddf" "Output person casedata file"
'===========================================================================================
' Default value for parameters
#ifndef SELECT_QUERY
#define SELECT_QUERY "SELECT * FROM HDATA.Person"
#endif
#ifndef OUTPUT_METADATA
#define OUTPUT_METADATA "\\server\share\person.mdd"
#endif
#ifndef OUTPUT_CASEDATA
#define OUTPUT_CASEDATA "\\server\share\person.ddf"
#endif
' Clean output files
Event(OnBeforeJobStart, "Clean output files")
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(OUTPUT_METADATA) Then fso.DeleteFile(OUTPUT_METADATA)
If fso.FileExists(OUTPUT_CASEDATA) Then fso.DeleteFile(OUTPUT_CASEDATA)
End Event
InputDatasource(myInputDataSource)
ConnectionString = " _
Provider = mrOleDB.Provider.2; _
Data Source=mrDataFileDsc; _
Location = C:\Program Files\IBM\SPSS\DataCollection\6\DDL\Data\Data Collection File\household.ddf; _
Initial Catalog = C:\Program Files\IBM\SPSS\DataCollection\6\DDL\ Data\Data Collection File\household.mdd"
SelectQuery = SELECT_QUERY
End InputDatasource
OutputDatasource(myOutputDataSource)
ConnectionString = " _
Provider = mrOleDB.Provider.2; _
Data Source = mrDataFileDsc; _
Location = " + OUTPUT_CASEDATA
MetaDataOutputName = OUTPUT_METADATA
End OutputDatasource
Event(OnJobEnd)
Dim COMPLETION_CODE
' COMPLETION_CODE value decided by user logic
Set COMPLETION_CODE = 1000
End Event
The #define directive is used to substitute text in a source file and to define identifiers whose values can be tested in an #if directive.
2: .dms parameters as displayed in the IBM SPSS Collaboration and Deployment Services job step
The defined .dms parameters displays in the IBM SPSS Collaboration and Deployment Services job step.
3: Exposing the .mrs script parameters
'===============================================================
' Parameter Definition Help:
' 1. ?? - Input parameters definition
' 2. @@ - Output variables definition
' 3. $$ - Output files definition
'===========================================================================================
' <PARAM_NAME> <TYPE> <DEFAULT_VALUE> <DESCRIPTION>
'--------------------+--------+------------------------------+------------------------------
'?? REPORT_TITLE MDD "Test Report" "Report title"
'?? INPUT_METADATA MDD "\\server\share\person.mdd" "Input person metadata file"
'?? INPUT_CASEDATA DDF "\\server\share\person.ddf" "Input person casedata file"
'@@ COMPLETION_CODE Long "0" "Job completion status code"
'$$ OUTPUT_REPORT HTML "\\server\share\report.htm" "Output metadata file"
'===========================================================================================
' Default value for parameters
#ifndef REPORT_TITLE
#define REPORT_TITLE "Test Report"
#endif
#ifndef INPUT_METADATA
#define INPUT_METADATA "\\server\share\person.mdd"
#endif
#ifndef INPUT_CASEDATA
#define INPUT_CASEDATA "\\server\share\person.ddf"
#endif
#ifndef OUTPUT_REPORT
#define OUTPUT_REPORT "\\server\share\report.htm"
#endif
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
' Delete output if it exists with an S
If fso.FileExists(OUTPUT_REPORT) Then
fso.DeleteFile(OUTPUT_REPORT)
End If
Dim TableDoc
Set TableDoc = CreateObject("TOM.Document")
' Load dataset
TableDoc.DataSet.Load(INPUT_METADATA, , INPUT_CASEDATA, "mrDataFileDsc")
' Create the table with the name "Table1", the Age variable on the side axis,
' the Gender variable on the top axis, and a heading of "My First Table"
TableDoc.Tables.AddNew("Table1", "age * gender", REPORT_TITLE)
' Populate the table
TableDoc.Populate()
' Export the table
With TableDoc.Exports.mrHtmlExport
.Properties["DisplayLogo"] = False
.Properties["Interactive"] = False
.Properties["OverwriteOutput"] = True
.Properties["DisplayOption"] = "Table Only"
.Export(OUTPUT_REPORT)
End With
The #define directive is used to substitute text in a source file and to define identifiers whose values can be tested in an #if directive.
4: .mrs parameters as displayed in the IBM SPSS Collaboration and Deployment Services job step
The defined .mrs parameters display in the IBM SPSS Collaboration and Deployment Services job step.
Only the output file location can be changed; the file name cannot be changed. The location can be a local path, a network share location, or a repository location.
5: Using COMPLETION_CODE in the IBM SPSS Collaboration and Deployment Services job step
The following image illustrates the process of defining COMPLETION_CODE in the IBM SPSS Collaboration and Deployment Services job step.
See also