Can I pass a variable to FME to replace a fixed value within a workspace

From Fmepedia


Image:Tip-or-sq-33pc.jpg   The information here is designated one of the  

Top 20 FME Tips

that are the most cool, interesting or useful.





Table of contents


Q) Can I pass a variable to FME to replace a fixed value within a workspace?

A) Values can be passed into Workbench using what are known as MACROs. The underlying functionality of MACROs has been exposed as parameters in Workbench. A parameter can be set and passed for a Transformer setting or a dataset read/write setting.

To set a parameter go to the Workspace tab in the navigation pane of Workbench.



Setting a transformer parameter

For transformers Locate the Transformers section. This shows a list of transformers used in your workspace. Expand the transformer of interest and locate the required setting. Right-click the setting and choose Publish Parameter. This brings up a dialog that lets you set the default value of this parameter, a prompt for the parameter and a parameter name. Set these and click OK. The parameter is now published. When the Prompt+Run function is used in Workbench you will be prompted to set a value for this parameter. When you run the workspace from the command line you are able to pass through a value for that parameter.

For example: in an AttributeSetter instead of setting the ‘value’ field to a fixed value you could use a parameter.


Above: Here an AttributeSetter value is about to be published.


Above: Publishing the parameter brings up a dialog which this user has edited to his requirements.


Above: On running the workspace the user is prompted for a value for this parameter.


Above: The log file reports the value provided in a form that can be used to run the translation from the command line.



Setting a dataset parameter

Locate the dataset and expand it to show all the settings. Right-click the setting and choose Publish Parameter. This brings up a dialog that lets you set the default value of this parameter, a prompt for the parameter and a parameter name. Set these and click OK. The parameter is now published. When the Prompt+Run function is used in Workbench you will be prompted to set a value for this parameter. When you run the workspace from the command line you are able to pass through a value for that parameter.

For example: an Oracle reader requires a password. The password setting can be published so the user is prompted on running the translation.


Above: Here an Oracle password is about to be published.


Above: Publishing the parameter brings up a dialog which this user has edited to his requirements.


Above: On running the workspace the user is prompted for a value for this parameter.


Above: The log file reports the value provided in a form that can be used to run the translation from the command line.



Setting a feature type parameter

Do this the same way as for a dataset parameter.


Above: Feature Type parameters are found in the Feature Types part of a Dataset within the Workbench navigation pane. Here are the reading parameters for a feature type belonging to an Oracle dataset.



Creating a user defined parameter

To create a user defined parameter - one that is detached from any particular transformer, dataset or feature type - see the section on Standalone_Published_Parameters.

Attached Files
filesizedate
FeatureTypeParams.jpg42.9 kB09/25/06
OracleLogCommandLine.jpg40.9 kB09/25/06
OracleParamPrompt.jpg16.3 kB09/25/06
logCommandLine.jpg32.7 kB09/25/06
oracleParamDialog.jpg19.8 kB09/25/06
oraclePublishParam.jpg44.7 kB09/25/06
paramdialog.jpg19.1 kB09/25/06
paramprompt.jpg13.4 kB09/25/06
publishparam.jpg32.4 kB09/25/06
User Comments Add a new comment