DLYJOBLOOP DELAY JOB LOOP TAAJODU |
The Delay Job Loop command simplifies the case where you are in a
loop waiting for some event to occur such as a subsystem to end.
Because some unusual event might occur, good coding practice would be
to place a limit on the number of times the program will wait for the
event to occur. DLYJOBLOOP supports a LOOPLIMIT parameter that
allows the command to send the CPF9898 escape message if the limit is
reached.
While the coding for a loop with a limit may appear to be trivial, it
is easy to make a mistake and loop forever. Few users will bother to
test their code to see what happens if the limit is reached.
DLYJOBLOOP makes it less likely that a mistake will occur.
A typical series of commands would be:
DCL &STATUS *CHAR LEN(10)
DCL &LOOPCOUNT *DEC LEN(5 0)
.
LOOP: RTVSBSD SBSD(xxxx) STATUS(&STATUS)
IF (&STATUS *NE '*INACTIVE') DO /* Not inactive */
DLYJOBLOOP SECONDS(15) LOOPLIMIT(10) +
LOOPCOUNT(&LOOPCOUNT)
GOTO LOOP
ENDDO /* Not inactive */
CHGVAR &LOOPCOUNT 0
/* Subsystem is now *INACTIVE */
The loop is waiting for the subsystem to reach an *INACTIVE state.
The loop will be done 10 times with a wait of 15 seconds each time
thru the loop.
The LOOPCOUNT parameter must be declared as *DEC LEN(5 0). The value
is incremented by the DLYJOBLOOP command each time it is run.
If DLYJOBLOOP is run 11 times, the CPF9898 escape message would
occur.
Note at the end of the loop that &LOOPCOUNT is reset to 0. Good
practice is to reset the value when the loop is successful so that if
you need the loop again, the value is set correctly.
Multiple uses of DLYJOBLOOP
---------------------------
If you are using DLYJOBLOOP at multiple points within your program or
re-using a DLYJOBLOOP loop a second time, the the LOOPCOUNT variable
must be reset to 0 at the beginning of the loop.
If you need DLYJOBLOOP within another loop that is using DLYJOBLOOP,
use a different variable name for LOOPCOUNT.
Good practice is to set the LOOPCOUNT variable to 0 at the successful
conclusion of a loop.
DLYJOBLOOP escape messages you can monitor for
----------------------------------------------
CPF9898 The loop limit has been reached.
Escape messages from based on functions will be re-sent.
Command parameters *CMD
------------------
SECONDS The number of seconds to delay the job.
LOOPLIMIT The number of times the loop may be run before the
CPF9898 escape message is sent. If you specify 10,
the DLYJOBLOOP command would issue the escape on the
11th time it is used.
LOOPCOUNT The number of times the loop has occurred. The
variable must be declared as *DEC LEN(5 0).
DLYJOBLOOP will increment the value by 1 each time
the command is used.
If you are using DLYJOBLOOP at multiple points
within your program or re-using a DLYJOBLOOP loop a
second time, the the LOOPCOUNT variable must be
reset to 0 at the beginning of the loop.
If you need DLYJOBLOOP within another loop that is
using DLYJOBLOOP, use a different variable name for
LOOPCOUNT.
Good practice is to set the LOOPCOUNT variable to 0
at the successful conclusion of a loop.
Restrictions
------------
Because DLYJOBLOOP uses a return variable, the command may only be
used in a CL program.
Prerequisites
-------------
The following TAA Tools must be on your system:
SNDESCINF Send escape information
SNDESCMSG Send escape message
Implementation
--------------
None, the tool is ready to use.
Objects used by the tool
------------------------
Object Type Attribute Src member Src file
------ ---- --------- ---------- ----------
DLYJOBLOOP *CMD TAAJODU QATTCMD
TAAJODUC *PGM CLP TAAJODUC QATTCL
|
Added to TAA Productivity tools February 1, 2005