@CMD and @JCL – Check RC of previous command or JCL step
This function compares the return code of a previous Workload Automation Programming Language command, or a previous JCL step in the same job, with a specified value.
The command returns 1 if the comparison is true, or 0 if the comparison is false.
@CMD([<label>.]EQ|NE|LT|LE|GT|GE.]<value>)
@JCL([[<label>.]EQ|NE|LT|LE|GT|GE|EM|NM.]<value>)
<label>
- Workload Automation Programming Language label of the command or step name within the job currently running.
EQ
- Is true if the return code is equal to
<value>
. NE
- Is true if the return code is not equal to
<value>
. LT
- Is true if the return code is less than
<value>
. LE
- Is true if the return code is less than equal to
<value>
. GT
- Is true if the return code is greater than
<value>
. GE
- Is true if the return code is greater than or equal to
<value>
. EM
- Is true if the abend matches the mask specified as
<value>
(@JCL
only). NM
- Is true if the abend does not match the mask specified as
<value>
(@JCL only
). <value>
- The value with which the return code or abend is being compared.
For @JCL
, the <label>
can
be STEPNAME.PROCSTEP
or PROCSTEP
,
where PROCSTEP
is the actual step name running
the program (whether it is in a job or a procedure), and STEPNAME
is
the name of the step calling the procedure where the step runs. If
the same PROCSTEP
occurs more than once, the
return code of the latest step is returned if only the PROCSTEP
is
specified. If more than one combination of STEPNAME.PROCSTEP
exists
within the job, the latest is used.
Examples:
@JCL(STEP0040.EQ.0)
allows a command to run when STEP0040 has a return code of 0.@JCLL(RUNWAPL.EQQYXTOP.EQ.4)
allows a command to run when a step called RUNWAPL calling the Workload Automation Programming Language procstep EQQYXTOP ends with return code of 4.@JCL(EQQYXTOP.EQ.4)
allows a step to run when the latest step using the name EQQYXTOP occurs.
For both @JCL
and @CMD
,
a positive number can be used for <label>
to
reference an absolute step or command number, for example 1 for the
first step, 3 for the third command. Negative numbers can be used
for relative steps or command, for example -1 for the immediately
previous step, -2 for the command before the last one.
- Workload Automation Programming Language automatically
runs commands on your behalf, and some commands may internally run
other commands to achieve their goal. Use
SHOW RC(5)
to see all the commands that have run up to that point. UsingSHOW RC
without specifying a message level, lists all commands up to and including the current value ofOPTIONS MSGLEVEL
. - The
SHOW RC
command lists the names of all steps in the job, including the Workload Automation Programming Language step currently running. This step, however, is not used when looking up steps by name, because it is not a preceding step. You can reference the step currently running by the relative address of 0, as follows:VARSET THISSTEP ENVATTR(JCL,STEP,0)
, and then useVARSET
to find out details of the running step.
<label>
in @CMD
, @JCL
and VARSET
:LAST_RC
- Refers to the previous JCL step or Workload Automation Programming Language command.
LAST_XRC
- Refers to the preceding JCL step or Workload Automation Programming Language command that was actually run.
MAX_RC
- Refers to the step that set the maximum return code.
MAX_RESP
- Refers to the step that set the maximum response code (for
LISTSTAT
).
For @JCL
, the MAX_RC
label
points to the step issuing the highest return code, unless an ABEND
has occurred, when this will be the last abended step, to allow for
situations where ONLY
and EVEN
is
used. For MAX_RC
and MAX_RESP
,
if SETMAX
is used to lower the maximum return
code, it will point to the step issuing the highest return code from
that point, which could be the SETMAX
statement
itself.
If the <label>
is not specified,
the last executed step or command is used (LAST_XRC
).
This default can be altered by OPTIONS IFJCL
or OPTIONS
IFCMD
as appropriate. For example, @CMD(EQ.0)
would
allow only a command to run if the last command that was not flushed
ended with a return code of 0.
If both <label>
and the comparator
are not specified, <label>
defaults
to LAST_XRC
and the comparator defaults to EQ
.
For example, @CMD(0)
would allow only a command
to run if the last executed command ended with return code 0.