The obvious and preferred way to ensure Dispatch is down and that it came down “clean” would be to review the logs generated by the started task that was ended. However, this requires a manual effort. In today's automated operations world, there may not be anyone available to review the Dispatch logs prior to running batch maintenance or a utility job against the Dispatch database.
Is there a way to verify that the Dispatch started task is not active before attempting to run a batch job against it that doesn’t require a manual effort?
To ensure that Dispatch is DOWN before running a batch job against it, consider the following;
The CADSBR01 proc located in your Dispatch installed 11.7 CADSPROC library contains the following step which is used to verify that Dispatch is down. If Dispatch is not down, the step will receive a U3017 abend:
//*------------------------------------------------------------------*
//* DATABASE LOCK CHECK - WILL ABEND IF LOCK IS ON
//*------------------------------------------------------------------*
//CHECKDB EXEC PGM=IDMSDUMP,REGION=512K
//STEPLIB DD DSN=&LOADLIB,DISP=SHR
//SYSGEN DD DSN=&DSHLQ..SYSGEN,DISP=SHR
//SYS001 DD DUMMY
//SYSLST DD DUMMY
//*------------------------------------------------------------------*
You could incorporate the above step into your version of the batch job you will be running as the first step, and then do some return code checking against this step to verify it ends with RC=00 before the job continues.
PLEASE BE ADVISED!
Addition of this step simply verifies that the "in use" flag for the SYSGEN database file is not ON (i.e. ALREADY IN USE). If the file is not locked opened, the step will end with RC=00 which would indicate that Dispatch is in fact down.
The step does NOT verify that Dispatch actually came down CLEAN. Only that the SYSGEN file is not opened or in use.
The only way to ensure that Dispatch came down CLEAN would be a manual process of reviewing the logs from the time of the shutdown.