Working With Workflow Variables
Working With Workflow Variables
Working With Workflow Variables
By PenchalaRaju.Yanamala
You can create and use variables in a workflow to reference values and record
information. For example, use a variable in a Decision task to determine whether
the previous task ran properly. If it did, you can run the next task. If not, you can
stop the workflow.
Use workflow variables when you configure the following types of tasks:
Use the Expression Editor to create an expression that uses variables. When you
build an expression, you can select predefined variables on the Predefined tab.
You can select user-defined variables on the User-Defined tab. The Functions
tab contains functions that you use with workflow variables. Use the point-and-
click method to enter an expression using a variable.
Use the following keywords to write expressions for user-defined and predefined
workflow variables:
AND
OR
NOT
TRUE
FALSE
NULL
SYSDATE
Related Topics:
Each workflow contains a set of predefined variables that you use to evaluate
workflow and task conditions. Use the following types of predefined variables:
Tip: When you set the error severity level for log files to Tracing in the
PowerCenter Server setup, the workflow log displays the values of workflow
variables. Use this logging level for troubleshooting only.
Table 4-1 lists the task-specific workflow variables available in the Workflow
Manager:
All predefined workflow variables except Status have a default value of null. The
Integration Service uses the default value of null when it encounters a predefined
variable from a task that has not yet run in the workflow. Therefore, expressions
and link conditions that depend upon tasks not yet run are valid. The default
value of Status is NOTSTARTED.
Related Topics:
Evaluating Task Status in a Workflow
$<TaskName>.<predefinedVariable>
2.Add a Start task and both sessions to the workflow.
3.Place a Decision task after the session that updates the local orders database.
Set up the decision condition to check to see if the number of workflow runs is
evenly divisible by 10. Use the modulus (MOD) function to do this.
4.Create an Assignment task to increment the $$WorkflowCount variable by one.
Link the Decision task to the session that updates the database at
headquarters when the decision condition evaluates to true. Link it to the
5.Assignment task when the decision condition evaluates to false.
When you configure workflow variables using conditions, the session that
updates the local database runs every time the workflow runs. The session that
updates the database at headquarters runs every 10th time the workflow runs.
Conceptually, the Integration Service holds two different values for a workflow
variable during a workflow run:
The start value is the value of the variable at the start of the workflow. The start
value could be a value defined in the parameter file for the variable, a value
saved in the repository from the previous run of the workflow, a user-defined
initial value for the variable, or the default value based on the variable datatype.
The Integration Service looks for the start value of a variable in the following
order:
For more information about datatype default values, see Table 4-2.
For example, you create a workflow variable in a workflow and enter a default
value, but you do not define a value for the variable in a parameter file. The first
time the Integration Service runs the workflow, it evaluates the start value of the
variable to the user-defined default value.
If you declare the variable as persistent, the Integration Service saves the value
of the variable to the repository at the end of the workflow run. The next time the
workflow runs, the Integration Service evaluates the start value of the variable as
the value saved in the repository.
If the variable is non-persistent, the Integration Service does not save the value
of the variable. The next time the workflow runs, the Integration Service
evaluates the start value of the variable as the user-specified default value.
If you want to override the value saved in the repository before running a
workflow, you need to define a value for the variable in a parameter file. When
you define a workflow variable in the parameter file, the Integration Service uses
this value instead of the value saved in the repository or the configured initial
value for the variable.
The current value is the value of the variable as the workflow progresses. When
a workflow starts, the current value of a variable is the same as the start value.
The value of the variable can change as the workflow progresses if you create an
Assignment task that updates the value of the variable.
If the variable is persistent, the Integration Service saves the current value of the
variable to the repository at the end of a successful workflow run. If the workflow
fails to complete, the Integration Service does not update the value of the
variable in the repository.
The Integration Service states the value saved to the repository for each
workflow variable in the workflow log.
If the Integration Service cannot determine the start value of a variable by any
other means, it uses a default value for the variable based on its datatype.
Table 4-2 lists the datatype default values for user-defined workflow variables:
1.In the Workflow Designer, create a new workflow or edit an existing one.
2.Select the Variables tab.
3.Click Add.
4.Enter the information in Table 4-3 and click OK:
Table 4-3. Options for Declaring User-Defined Workflow Variables
Field Description
Name Variable name. The correct format is $$VariableName. Workflow
variable names are not case sensitive.
Do not use a single dollar sign ($) for a user-defined workflow
variable. The single dollar sign is reserved for predefined workflow
variables.
Datatype Datatype of the variable. You can select from the following datatypes:
-Date/Time
-Double
-Integer
-Nstring
Persistent Whether the variable is persistent. Enable this option if you want the
value of the variable retained from one execution of the workflow to
the next.
Default Default value of the variable. The Integration Service uses this value
Value for the variable during sessions if you do not set a value for the
variable in the parameter file and there is no value stored in the
repository.
Variables of type Date/Time can have the following formats:
-MM/DD/RR
-MM/DD/YYYY
-MM/DD/RR HH24:MI
-MM/DD/YYYY HH24:MI
-MM/DD/RR HH24:MI:SS
-MM/DD/YYYY HH24:MI:SS
-MM/DD/RR HH24:MI:SS.MS
-MM/DD/YYYY HH24:MI:SS.MS
-MM/DD/RR HH24:MI:SS.US
-MM/DD/YYYY HH24:MI:SS.US
-MM/DD/RR HH24:MI:SS.NS
-MM/DD/YYYY HH24:MI:SS.NS
You can use the following separators: dash (-), slash (/), backslash (\),
colon (:), period (.), and space. The Integration Service ignores extra
spaces. You cannot use one- or three-digit values for year or the
“HH12” format for hour.
Variables of type Nstring can have a maximum length of 600
characters.
Is Null Whether the default value of the variable is null. If the default value is
null, enable this option.
Description Description associated with the variable.
To validate the default value of the new workflow variable, click the Validate
5.button.
6.Click Apply to save the new workflow variable.
7.Click OK.