PCHKACT program for IBM ISeries AS/400 AS400

Introduction

PCHKACT checks whether a particular job - identified only by the 6-digit job number - is active on your ISeries (AS/400, AS400) machine. You pass in the parameter job number and PCHKACT returns a boolean (Y/N) parameter indicating if that job number is active. This is one of the commands in our ISeries utilities library (click this URL for full contact and pricing details).

Normally when you check a particular ISeries job (e.g. using the DSPJOB command), you need the three full job identifiers Name/User/Number (10+10+6 characters). Some applications use the job number only e.g. to record the number of the job which is currently locking a particular record or file. These applications typically first post their own job number to lock out other jobs, then blank this out later when they have finished. If this second step fails, the lock is held indefinitely - or until some control function checks whether that job is actually still active. This check can be done by PCHKACT.

There is no IBM-supplied ISeries command which works on job number only. There are two ways to get job details given only a job number. The first is to use WRKACTJOB with OUTFILE output, which is *very* resource-intensive. The second way - used by PCHKACT - is to use APIs, which is much quicker.

A job is deemed 'active' if it is currently executing. Jobs that are on a job queue (status *JOBQ) or that have completed execution with spool files remaining (status *OUTQ) are both deemed inactive.


Examples

DCL VAR(&JOBNO) TYPE(*CHAR) LEN(6) VALUE('076543')
DCL VAR(&ACT) TYPE(*CHAR) LEN(1)
CALL PGM(PCHKACT) PARM(&JOBNO &ACT)

CL commands above check whether job number 076543 is active.


Restrictions

1) It is possible, but extremely unlikely, that two different jobs with the same job number exist on your ISeries. That is, a first job is still there after 999999 more job numbers have been assigned. If any of the duplicate job numbers are active, PCHKACT returns an active flag.
2) If a particular job number never existed, PCHKACT simply returns an inactive flag.
3) The job number parameter passed to PCHKACT must be exactly 6 characters long. Leading blanks are allowed. For example, the value ' 23456' is expanded internally to '023456'.
4) PCHKACT conservatively assumes that a job number is active until proven otherwise. That is, the return boolean parameter is first initialised to 'Y'. If PCHKACT encounters an internal error (e.g. not authorised to API), a job may be incorrectly identified as active. If you encounter this condition, you may want to run CHGPGM PGM(PCHKACT) USRPRF(QSECOFR) USEADPAUT(*YES).

IBM rebranded the AS/400 - some users called it AS400 - to ISeries several years ago. All 3 names - ISeries, AS/400, AS400 - refer to exactly the same system.