The Check Active Program command is intended to provide an 'If
i5/OS CL does not support such a command, but a similar function
exists in S/36E.
Outside of S/36E, when a program is called, i5/OS does not lock the
program. To determine if the program is in use, a user must specify
that a lock is needed. CHKACTPGM performs this function.
The normal use of CHKACTPGM is to include it in the program that
wants to ensure it has only a single use. The following code is in a
format so it can be directly copied into a program using SEU.
DCL &MSGDTA *CHAR LEN(120)
CHKACTPGM /* TAA tool command */
MONMSG MSGID(CPF9898) EXEC(DO) /* Already active */
RCVMSG MSGTYPE(*EXCP) MSG(&MSGDTA)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGTYPE(*ESCAPE) +
ENDDO /* Already active */
CHKACTPGM will attempt to place an *EXCL lock on the current program.
If the lock cannot be achieved, CPF9898 is sent as an escape message.
In the sample code, the CPF9898 message sent by CHKACTPGM is resent
by the program. The text would read:
Program XXXX in YYYY is already in use by another job
and can only be used by one job at a time.
The typical use for CHKACTPGM is in a batch job where a sensitive
program needs to be run without any other job running the same
program at the same time. When the batch job ends, the system
automatically releases any locks. If you are in an interactive job
or wish to end the lock earlier in the batch job, specify:
. /* Normal processing */
You can also use CHKACTPGM to determine if a lock can be achieved
with ALLOCATE(*TEST). This will perform both an ALCOBJ and DLCOBJ
You can specify CHKACTPGM and name a program. However, the named
program must have a lock placed on it to allow CHKACTPGM to operate
Command parameters *CMD
PGM The qualified program name to be allocated or
deallocated. The default is * meaning the current
program. If * is used, the program must exist on
the library list.
The program cannot start with a Q (this prevents a
user at the command entry display from locking
If a specific program is named, the test will only
be successful if the named program is also using
CHKACTPGM or ALCOBJ has been used in the job to lock
the program. If a specific program is named without
a library qualifier, *LIBL is assumed.
ALLOCATE The type of allocation. *LOCK is the default
meaning to attempt to lock the program with an *EXCL
lock. You can lock an object more than once in the
same job. Each lock is unique. Therefore, if you
use CHKACTPGM with *LOCK multiple times in the same
program, you would have a unique lock for each use.
*UNLOCK may be specified to unlock the program. The
command will complete normally regardless of whether
a lock had been held or not. The system does not
send an escape message if the object is not
currently locked by the same job.
*TEST may be specified to determine if an *EXCL lock
can be achieved. This performs both an allocate and
deallocate function. If the object can be locked,
it is automatically unlocked on return.
If a specific program is named, the test will only be successful if
the named program is also using CHKACTPGM or any job using the
program has run ALCOBJ and locked the program.
If PGM(*) is used, the program must exist on the library list.
The program name must not start with a Q.
The following TAA Tools must be on your system:
SNDCOMPMSG Send completion message
SNDESCMSG Send escape message
None, the tool is ready to use.
Objects used by the tool
Object Type Attribute Src member Src file
------ ---- --------- ---------- ----------
CHKACTPGM *CMD TAAPGMG QATTCMD
TAAPGMGC *PGM CLP TAAPGMGC QATTCL