:RSET
The R in :RSET stands for Restart. The :RSET statement allows you to assign a value or the result of an arithmetic expression to a script variable while simultaneously creating or updating an object variable with the same name. This makes the script variable's value persistent; this means that it can be retrieved like any other object variable. Essentially, :RSET combines the assignment capability of :SET with the functionality of :PUBLISH (specifically, using TASK scope).
More Information:
Syntax
:RSETScript variable [= Value]
Parameters
-
Script variable
Name of the script variable to assign the value to.
Format: script variable
Follow the rules for variable names. For more information, see Variable Names. -
value
Value that is assigned to the script variable and object variable.
Format: Arithmetic expression, script literal, number, script variable, or script function.
Usage
You can use the :RSET statement to generate object variables on the following places or for the following purposes:
-
On the Pre-Process or Process page to then use them on the Post Process page of an object definition. For more information, see Defining the Process Pages in Jobs.
-
To use them during a restart. When restarting a task, the restarted task inherits all object variables from the reference run. For more information, see Restarting Tasks.
-
To use them later on in subsequent tasks by using the script function GET_PUBLISHED_VALUE.
-
On the Process page of a Workflow to pass them to its child tasks. For that to work, you must configure child tasks in a Workflow to inherit object variables from the parent. Use the Inherit from parent setting on the Variables page in the object definition of the child task. Store script variables and their values in the activation report. For more information about activation reports, see Understanding the Reports. See also Defining the Variables Page.
Important!
-
End the variable name with a delimiter such as a hash. This avoids errors when generating child tasks where the names of the object variable and the Workflow task start with the same characters.
-
If a task that uses the :RSET statement to create an object variable was canceled before processing its script, the object variable will not exist if being restarted.
Activation Report
In the past, the script variable and its value were stored in the activation report and restored from there when restarted. To remain compatible, the script variable is still stored in the activation report. Every value, including values of type signed or float, will be stored as a text.
The line that is written to the activation report looks like the following example:
YYYY-MM-DD HH:MM:SS - U00020206 Variable '&VAR#' was stored with the value 'VALUE'.
Example 1
Generate a script variable named &TODAY# during the original run on the Process page that is persisted as an object variable. If this task is restarted, the script variable &TODAY# already exists and contains the value from the original run.
:IF SYS_ACT_RESTART () = "N"
: RSET &TODAY# = SYS_DATE (YYMMDD)
:ENDIF
Example 2
A Job uses the :RSET statement to create an object variable named &HOST#. If this Job is executed but canceled before its script is generated, the &HOST# object variable does not exist. In this case, you could use the following method to check that:
:SET &HOST# = "&HOST#"
:IF &HOST# = ""
: RSET &HOST# = "UNIX01"
:ENDIF
Example 3
Generate a script variable named &TODAY# during the original run on the Process page of a Job that is persisted as an object variable.
:RSET&TODAY# = SYS_DATE (YYMMDD)
On the Post Process page, for each object variable a script variable is generated. This means that you can use &TODAY# directly or add the following line to read its current value directly from the database:
:RSET&TODAY#
Tip: You can use the :RSET and :READ script statements to store values of script variables in reports.
See also: