Advanced Scheduling 1: Building Chains of Jobs

Procedure

Target

Assume that you irregularly have to schedule a chain of jobs, that is, a set of jobs linked by predecessor-successor relationships.

You want to consolidate the scheduling of this chain of jobs into a single job that sees to the scheduling of all jobs in the chain. The advantage of this consolidation: You need only to schedule a single job to launch the chain of jobs.

Scheduling a Job Chain

Introduction

You implement this job in three small ABAP reports. These show both:

  • a loose, informal predecessor-successor relationship (between Jobs 1 and 2, no guarantee that Job 1 completes before Job 2); and

  • a tight relationship using the start after predecessor mechanism of the background processing system (between jobs 2 and 3). Here, there is a guarantee that Job 2 finishes before Job 3. In this case, there is even a guarantee that Job 2 has completed successfully before Job 3 can start.

The first report schedules Job 1 to run immediately. Job 1 does some work and schedules both Job 2 and Job 3. There is no formal predecessor/successor relationship between Jobs 1 and 2. Usually, Job 2 won't start until Job 1 processing has been completed. But it is possible for steps in Jobs 1 and 2 to overlap. For example, if Program_X in Job 1 is an external program and Job 1 does not wait for Program_X to complete, then Program_Y in Job 2 and Program_X in Job 1 could overlap.

Job 1 must schedule both Jobs 2 and 3 because a job cannot schedule its own successor. This is because a predecessor job must have the status Scheduled or Released when a successor job is scheduled. If you want to set up chains of jobs, do so from a single initial report or job, as in this example.

Job 2, in turn, runs to completion and triggers the start of Job 3. Here, Job 3 is formally linked to Job 2 as its predecessor, using the pred_jobname argument of the JOB_CLOSE function module. The predjob_checkstat argument ensures that Job 3 will start only if Job 2 is successfully completed. For a programming sample, see Sample Program: Wait for Predecessor Job with JOB_CLOSE.

(An alternative to the strategy shown here would be to schedule the jobs in the chain to run periodically. But this is a good solution only if the jobs must run according to a regular schedule. Also, the jobs are not automatically rescheduled if one of them fails).