VARSUB – Control variable substitution
Use the VARSUB
command to control
how variable substitution is performed within Workload Automation Programming Language.
You can specify VARSUB
commands at any point
in the Workload Automation Programming Language command
stream, except within a Batch Loader construct for an object.
VARSUB [SCAN[(prefix,suffix)]|NOSCAN] [CLOSE[(table)]] [SEARCH(list)]
[TABLE(table)] [VARFAIL(ASIS|FAIL|NULL)]
SCAN[(prefix,suffix)]
- Activates Workload Automation Programming Language variable
substitution. Without any arguments, the variable prefix is set to
an exclamation mark (!) and the suffix to a period (.). For example,
VARSUB SCAN
results in a variable convention like!MYVAR.
By setting prefix and suffix, you can modify the way variables are specified. For example,VARSUB SCAN(<,>)
results in a variable convention like<MYVAR>.
Note: If you use the same character for prefix and suffix, you must specify both the prefix and suffix each time a variable immediately follows another variable, such as in%MYVAR1%%MYVAR2%
When aVARSUB SCAN
statement is found, it automatically opens the Application and Global tables.If you want to open only specific tables, use theSEARCH
keyword before theSCAN
keyword, as in the following example:VARSUB SEARCH(MYTABLE,NOAPPL,NOGLOBAL) SCAN
NOSCAN
- deactivates Workload Automation Programming Language variable
substitution. The table search sequence is left as it is; if variable
substitution is activated again in the statements, the same search
sequence is used.If substitution is being deactivated and you don not plan to activate it again in the Workload Automation Programming Language statements, close all open tables by using the
CLOSE
keyword in conjunction withNOSCAN
, as in the following example:VARSUB NOSCAN CLOSE
CLOSE[(table)]
- Closes a table and remove it from the search sequence. The variable
definitions and any dependencies are dropped from storage, so it is
good practice for systems with large tables or many dependent variable
values. It does not drop the value of any variable that has
already been referenced from the closed table, those values remain
accessible for the remainder of the Workload Automation Programming Language process.
You can close a single table, for example
VARSUB CLOSE(MYTABLE)
, or close all open tables, including the Application and Global tables, by not specifying a table name.If you need to close multiple tables, the
CLOSE
keyword can be repeated, for exampleVARSUB CLOSE(MYTABLE1) CLOSE(MYTABLE2)
SEARCH(table,table,table,APPL|NOAPPL,GLOBAL|NOGLOBAL)
- Sets the order in which tables are searched for variables. By
default, Workload Automation Programming Language first
searches tables opened with
TABLE
keywords, starting with the most recently opened. Then it searches the Application table (if one is specified for the occurrence running the Workload Automation Programming Language job) and the Global table.If not specified in the
SEARCH
keyword, the Application and Global tables are automatically added as the last 2 tables in the sequence. SpecifyingNOAPPL
means that the Application table is not searched, and specifyingNOGLOBAL
means that the Global table is not searched.For example:
VARSUB SEARCH(MYTABLE1,MYTABLE2)
sets the search sequence to MYTABLE1, then MYTABLE2, then the Application table, followed by the Global table.VARSUB SEARCH(MTABLE1,APPL,MYTABLE2)
sets the search sequence to MYTABLE1, then the Application table, then MYTABLE2, followed by the Global table.VARSUB SEARCH(MTABLE1,APPL,MYTABLE2,NOGLOBAL)
sets the search sequence to MYTABLE1, then the Application table, then MYTABLE2. The Global table is not searched.
Tables already open but not specified in the
SEARCH
keyword, are automatically closed. Tables that were not open and are specified in theSEARCH
keyword, are automatically opened. VARFAIL(ASIS|FAIL|NULL)
- Defines what to do if a variable referenced in a Workload Automation Programming Language statement
is not found:
ASIS
- The variable is left unresolved in the Workload Automation Programming Language statement.
FAIL
- The parsing for the statement fails and it is not performed (default).
NULL
- The variable is considered to have a null value and is assumed to belong to the first table in the table search sequence, at the point where it is referenced.
TABLE(table)
- Opens a table and add it to the front of table search sequence.
Opening a table loads the definition, including the dependencies,
of each variable within the table, but it does not set any values
of Workload Automation Programming Language variables.
This occurs only when a variable is referenced within a Workload Automation Programming Language statement.With the
TABLE
keyword you can open only one table at a time. To add multiple tables to the search sequence, you can repeat theTABLE
keyword as in the following example:VARSUB TABLE(MYTABLE1) TABLE(MYTABLE2)
Note: Because Workload Automation Programming Language first searches the latest opened table, the above command results inMYTABLE2
being searched beforeMYTABLE1
.
- The sequence of keywords on the
VARSUB
statement does affect the result of the command. VARSUB SCAN
turns on variable substitution for subsequent statements. Variables cannot be used within the sameVARSUB
statement that uses theSCAN
keyword. Hence,VARSUB SCAN TABLE(MYTABLE)
is valid, whileVARSUB SCAN TABLE(!OADID)
is not valid, because it uses a the variable!OADID
. These should be coded on separate statements, as in the following example:VARSUB SCAN(!) VARSUB TABLE(!OADID)