Professional > Data management scripting > Data Management Script (DMS) file > Sections in the DMS file > Event section > OnAfterMetaDataTransformation Event section
 
OnAfterMetaDataTransformation Event section
The OnAfterMetaDataTransformation Event section defines procedural code that is to be executed after the metadata defined in the Metadata section has been merged with the input metadata. Typically, you would use this section in a DMS file that creates variables in the Metadata section to set up card, column, and punch specifications or other custom properties for the new variables before exporting case data to a Quantum .dat file or an IBM SPSS Statistics.sav file.
The Job object, and all of the other objects to which it gives access (with the exception of the Questions collection) are available in the OnAfterMetaDataTransformation Event section. For more information, see Using objects in the Event sections.
The OnAfterMetaDataTransformation Event section is not available when you have not specified an input metadata source.
Example
The following example uses the Metadata Model to Quantum component to set up card, column, and punch definitions in the output metadata after the metadata defined in the Metadata section has been merged with the metadata specified in the InputDataSource section. It also uses the new MDSC capability of Quantum DSC to create a Quantum specification based on the card, column, and punch definitions. For more information, see The Quantum specification.
The Job.TransformedOutputMetadata property is used to get the name and location of the output metadata. If you have not specified an output metadata file name, this will be a temporary metadata file that is created during the transformation and then deleted.
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.
Event(OnAfterMetaDataTransformation, "Allocate card columns and create Quantum spec")
Dim M2Q, MDM

Set MDM = CreateObject("MDM.Document")
MDM.Open(dmgrJob.TransformedOutputMetaData[0])

' Create the MDM2Quantum object
Set M2Q = CreateObject("MDM2QuantumLib.MDM2Quantum")

' Set the MDM Document into the MDM2Quantum object
Set M2Q.MDMDocument = MDM

' Set the MDM2Quantum properties to use the standard Quantum
' setting of multiple cards with 80 columns. Delete these lines
' if you want to use one card of unlimited length

M2Q.SerialFullName = "Respondent.Serial"
M2Q.SerialColCount = 5
M2Q.CardNumColCount = 2
M2Q.CardNumColStart = 6
M2Q.CardSize = 80

' Run the allocation
M2Q.AllocateCardColPunch(True)

MDM.Save()

' Use the DSC Registration component to find Quantum DSC
Dim DMComp, dscQuantum
Set DMComp = CreateObject("MRDSCReg.Components")
Set dscQuantum = DMComp.Item["mrPunchDsc"]

' Write out the specs
dscQuantum.Metadata.Save(MDM, "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\OnAfterMetadataTransformation\MySpec", Null)

MDM.Close()

End Event
This example does not check for a DataSource object or set it as the current DataSource object for the Document. This is because the DataSource object is automatically set up in the output metadata and made the default DataSource.
This example does not call the MDM2Quantum.ClearCardColPunch method. This means that it will preserve any card, column, and punch definitions that have already been defined in the input metadata.
This example sets up the card, column, and punch definitions in the output metadata only. If you want to set up the card, column, and punch definitions in the input metadata in the OnAfterMetadataTransformation Event section as well, you would need to use Job.TransformedInputMetadata property to get the name and location of the input metadata and repeat the relevant code.
The MDM Document.Close method has been called to release the MDM Document. If you did not do this, an error occurs, typically containing the text “The process cannot access the file because it is being used by another process”.
This example is in a sample DMS file (OnAfterMetaDataTransformation.dms) and as a separate Include file (called CardColsExtra.dms) that are installed with the UNICOM Intelligence Developer Documentation Library. For more information, see Sample DMS files.
See also
Event section