ON RESTART Statement

The ON RESTART <statement> form of the ON statement can be used to specify actions to be taken if job execution is interrupted by a halt/load. Any statement or group of statements can be specified in the ON RESTART statement. The following kinds of actions might be desirable:

  • File and task variables can be reassigned the correct values.

  • Job execution can be restarted at a particular point in the job, by using a GO statement.

If a halt/load occurs in the middle of a job, job execution restarts at the most recent successful job rollout. If during the halt/load process the JOBDESC file is removed, all jobs are also removed. Therefore, no jobs are restarted. For details, refer to the ??RJ (Remove JOBDESC File) primitive command in the System Commands Reference.

The ON RESTART statement is processed after a halt/load only if a successful job rollout occurred after the ON RESTART statement.

Some jobs include statements that interrogate a task variable to find out whether a task completed successfully or abnormally. However, the value of the task variable is not retained across a halt/load. An alternative method for storing information about whether a task completed successfully is to declare a Boolean variable in the job expressly for this purpose, and assign a value of TRUE or FALSE to the variable after the task completes. The value of the Boolean variable is saved across a halt/load, so it can always be interrogated later.

A useful technique for keeping track of exactly how far job execution had progressed before a halt/load occurred is to declare an integer variable and increment the value of that variable at several stages during the job. The ON RESTART statement can include statements that inspect the value of this integer variable and cause different actions to occur according to the value stored.