Using variables to modify your text
Sometimes it is
convenient to leave certain details open, and fill them in at the
last moment. Suppose that you are writing definitions for some installation,
and you do not know the prefix used for table names at that installation. You
can then code everything, except for the prefix. Instead of the
prefix, you can write a marker that will be replaced by the prefix
at a later time. This marker, called a variable marker, has the
form of an ampersand (&) immediately followed by a word.
For example, you can write:
DEFINE UPDATE XYZ FROM &PREFIX.JOBSTAT_D TO ...
The variable marker is in this case &PREFIX. One way of specifying the actual prefix is by executing
a log collector statement such as:
SET PREFIX='ABC';
As explained in SET, this
statement defines a variablePREFIX with valueABC. From that moment on, whenever the log collector encounters
the marker &PREFIX, it logically replaces the marker by the value of the variable PREFIX. Thus, your statement will be processed as if you have coded:
DEFINE UPDATE XYZ FROM ABC.JOBSTAT_D TO ..
You may code the variable marker at any place you would code a token.
To properly terminate it, you might have to follow it with a blank
or a comment. Any lowercase letters in the variable marker are translated
to uppercase before the marker is used to identify the variable.
The replacement string can consist of any number of tokens, blanks,
and/or comments.An alternative way to define a variable is to code &PREFIX=ABC as a part of the parameter string supplied to the log collector
at the invocation. See Specifying JCL and parameters for details.
If you use variable markers, fill in the details when the log collector processes your text. If your text is, for example an update definition, this means all details are fixed before the definition is stored. Another method, described in Obtaining the value of a variable, lets you postpone this until the moment when the stored definition is actually used.