Query current program executing in a running batch job
search cancel

Query current program executing in a running batch job


Article ID: 264338


Updated On:


OPS/MVS Event Management & Automation


We are looking to block cancel commands for a batch job if it is running a certain Program.

Looking for advice if its possible to query a job and find what its currently executing program is.

From a message rule we can use OPSINFO('EXECPGM') but we need to query any job since the program we want to block from cancelling does not produce a WTO.



Release : 14.0


A message rule is the only way to take advantage of the OPSINFO('EXECPGM') function since the message rule executes within the same address space as the job. There is no other method available in OPS/MVS outside of a message rule to determine what program is currently executing in a batch job, and since the program in question does not issue a WTO, a message rule cannot be used.

However, if "batch job is running a certain Program" means that the current jobstep specified PGM=certainProgram, then adding the program to the PPT in the z/OS parmlib member SCHEDxx with the NC attribute should work without any involvement by OPS/MVS. The CANCEL command will honor the NC (not cancellable) attribute and will not cancel the job if the program is currently executing within the job. More information is available regarding the PPT and SCHEDxx parmlib member in the IBM documentation below: