Example - Changing a model object using MDL
The three supported methods are listed below:
- Update the definition with a script.
- Change the MDL definition directly.
- Update the definition within the model.
For the sample model Great Outdoors.mdl, suppose you want to change the source file for Products (CSV) from Prodinfo.csv to P0001.csv. The original definition of the data source is as follows:
DataSourceMake 103 "Products (CSV)" Separator ","
SourceType FlatFile_ColNames CharacterSet Multibyte DecimalSep "."
Thousandsep "," Columns True Timing
PopYesCreateNo
Source ".\samples\powerplay\cubes and reports\prodinfo.csv"
Speed False
SetCurrent False ServerSource False
Presummarized False EnableMultiProcess False
You can update the definition with a script that changes the data
source file to P0001.csv. This script opens the model, issues a DataSourceUpdate statement,
and saves the model.
OpenMDL "Great Outdoors.mdl"
DataSourceUpdate "Products (CSV)" Source "c:\Production\P0001.csv"
SaveMDL "Great Outdoors (Admin).mdl"
Alternatively, you can change the object definition in the model.
In this case, you can delete the word Prodinfo in
the DataSourceMake statement, and then replace it
with P0001.
This is the new DataSourceMake statement:
DataSourceMake 103 "Products (CSV)" Separator ","
SourceType FlatFile_ColNames CharacterSet Multibyte DecimalSep "."
Thousandsep "," Columns True Timing
PopYesCreateNo
Source "c:\Production\P0001.csv" Speed False
SetCurrent False ServerSource False Presummarized False
EnableMultiProcess False
You can also open the MDL model in a text editor and add this DataSourceUpdate statement
to the end of the model definition file:
DataSourceUpdate "Products (CSV)"
Source "c:\Production\P0001.csv"
The next time you open the model in Cognos
Transformer, the change will be implemented.
The original DataSourceMake statement is not altered,
but your addition remains in effect as long as the DataSourceUpdate statement
remains attached to the model definition.
UpdateForwardReference before
the statement that updates the object, as follows:UpdateForwardReference DataSourceUpdate "Products (CSV)"
Source "c:\Production\P0001.csv" For information about command line options that you can use when running scripts, see the Cognos Transformer User Guide. For sample MDL scripts, see Sample scripts.