Professional > Data management scripting > Data Management Script (DMS) file > Sections in the DMS file > Event section > Using objects in the Event sections
 
Using objects in the Event sections
If you are new to working with objects, see Introduction to objects.
Note If you explicitly call the MDM Document.Open method to open an MDM document, you need to call the Document.Close method to release the document. For more information, see OnAfterMetaDataTransformation Event section.
Objects in the OnJobStart, OnNextCase, OnBadCase, and OnJobEnd Event sections
In the following sections, the Data Management Object Model (DMOM) registers some objects with the mrScriptBasic engine:
OnJobStart Event section
OnNextCase Event section
OnBadCase Event section
OnJobEnd Event section
This means that the registered objects are automatically available in the script as intrinsic variables. However, DMOM requires an input metadata source to do this. This means that you cannot use these Event sections during a case data-only transfer or when are using a non-UNICOM Intelligence Data Model OLE DB provider to read the data.
The registered objects are:
Job
The Job object is of type IDataManagerJob, and is available as an intrinsic variable called dmghJob.
Although the Job object gives you access to the input and output metadata through the TransformedInputMetaData and TransformedOutputMetaData properties, these properties are designed to enable you to set up card, column, and punch definitions and other custom properties in the OnAfterMetaDataTransformation Event section. It is important that you do not make any changes to the structure of the input or output metadata in the OnJobStart, OnNextCase, OnBadCase, OnJobEnd, or OnAfterMetaDataTransformation Event sections. For example, you should not add or delete variables or categories or change a variable's data type.
If you have UNICOM Intelligence Reporter, the Job.TableDocuments property returns a collection of TableDocument objects, one for each output data source that is written using a CDSC that is also read-enabled. A TableDocument object is not available for non-Data Model format output data sources or Quantum-format output data sources (because the Quantum CDSC is not read-enabled). Although you can define your tables in the OnJobStart, OnNextCase, OnBadCase, OnJobEnd, and OnAfterMetadataTransformation Event sections, you cannot populate or export your tables in these sections. (Attempting to do so may lead to an error.) You should populate and export the tables in the OnAfterJobEnd Event section. For more information, see Table scripting in a data management script.
GlobalVariables
The GlobalVariables object is of type IDataManagerGlobalVariables and is available in the script as an intrinsic variable called dmgrGlobal. This collection enables you to share objects between the OnAfterMetaDataTransformation, OnJobStart, OnNextCase, OnBadCase, and OnJobEnd Event sections. For example, you can add an object to this collection in the OnJobStart Event section and access the object in the OnNextCase, OnBadCase, and OnJobEnd Event sections.
Global SQL variables
If you define any global SQL variables in the GlobalSQLVariables section, each global SQL variable is available with the name defined for it in the GlobalSQLVariables section.
Questions
The IQuestions object is available in the script as an intrinsic variable called dmgrQuestions. The Questions collection contains a IQuestions object for each variable included in the SelectQuery statement in the InputDataSource section. In addition, each of these variables is available as a Question object with the name specified in the SelectQuery statement. For example, if the SelectQuery statement contains the following SELECT statement, the mrScriptBasic will automatically contain Question objects called Respondent.Serial, age, and gender.
SELECT Respondent.Serial, age, gender FROM vdata
Questions are only created after the OnBeforeJobStart event and include content from the metadata section.
Log
The Log object is available as an intrinsic variable called dmgrLog. If your DMS file does not have a Logging section, no logging will be performed.
WeightEngines
The WeightEngines object is available as an intrinsic variable called dmgrWeightEngines and returns a collection of WeightEngine objects, one for each output data source. The WeightEngine objects are automatically initialized and so you do not need to call the WeightEngine.Initialize method. In fact calling this method is likely to lead to an error.
Objects in other object models can be accessed using the CreateObject function.
Objects in the OnAfterMetaDataTransformation Event section
In an OnAfterMetaDataTransformation Event section, the Data Management Object Model (DMOM) registers the Job object with the mrScriptBasic engine and it is available as an intrinsic variable called dmgrJob. You can access all of the properties on the Job object in this Event section except for the Questions collection, which is not available.
The Job object gives you access to the input and output metadata through the TransformedInputMetaData and TransformedOutputMetaData properties. These properties are designed to enable you to set up card, column, and punch definitions and other custom properties in the input and output metadata. It is important that you do not make any changes to the structure of the input or output metadata in this section. For example, you should not add or delete variables or categories or change a variable's data type.
The OnAfterMetaDataTransformation Event section requires an input metadata source. This means that you cannot use this Event section in a case data-only transfer or when are using a non-UNICOM IntelligenceData Model OLE DB provider to read the data.
Objects in the OnAfterJobEnd Event sections
Provided you have specified an input metadata source, the Job object is available as an intrinsic variable called dmgrJob in the OnAfterJobEnd Event section. You can access all of the properties on the Job object in this Event section except for the Questions collection, which is not available. If you have the Professional Tables Option, the Job.TableDocuments property returns a collection of TableDocument objects, one for each suitable output data source. See Table scripting in a data management script.
If you have not specified an input metadata source, you can use an OnAfterJobEnd Event section, but the Job object is not available.
Objects in other object models can be accessed using the CreateObject function.
Objects in the OnBeforeJobStart Event sections
The Job object, and the other objects listed above to which it gives access, are not available in the OnJobStart Event section. You need to use the CreateObject function to access any object in this section.
See also
Event section