Tips For Setting Up Batch Job Stream Definitions

Configuring job streams to avoid open-ended stream issue

The job streams should always be configured such that the stream “ends” only once all the steps in the stream are completed either by configuring it on the “end of stream” step condition or by defining the inter-dependencies between the steps. This ensures the stream run execution does not stop in the middle of the stream.

Jobs that run past midnight must have same business date as other jobs in a stream

In situations where a stream runs too long and has some jobs run past midnight, all jobs in the stream can be set to run with same business date. Create a scheduler program to set the business date program option value to ‘SYSDATE’ and job stream scope set to the stream name. Use this scheduler program as the initial step on the stream before other steps.

How to split a big stream into multiple smaller stream

If the Batch Job Stream Definition is too long with many jobs to run, it can be split into multiple smaller streams such that one stream runs after the other. This can be done using a new batch control K1-EXDJS (Execute DBMS Job Stream). Create a Scheduler Program for every sub stream, specify the batch control as K1-EXDJS, batch parameter name as the sub stream name. Use this scheduler program as a last step on the previous stream before it ends so that as soon as the previous stream’s steps are completed, the last step will initiate the new sub stream. For example, if you have a stream with jobs A,B,C,B,E,F,G,H. Split the stream into stream 1 with A,B,C,D and stream 2 with E,F,G,H. Create a Scheduler Program with batch control K1-EXDJS, batch parameter name as stream 2. On stream 1 after step D, define a new step that invokes the created Scheduler Program. Note that there are no dependencies between sub-streams. That is each sub stream would be kicked off by the new batch control to run on it’s own and the stream that called the sub stream does not wait for it to finish. So such configuration is to be used with only those steps that run in parallel.

How to configure streams to run only on OUAF working calendar dates

To setup Batch Job Stream Definition to run only on working days, use the batch control K1-CWCEL. Create a Scheduler Program with this batch control, batch parameter Work Calendar set to required work calendar, Verify that Run On Business Day is set to true. Use this Scheduler Program as the first step to run on the stream. Define the stream to end if this step fails. Define the stream’s subsequent step to execute if this step succeeds. When the stream runs on a scheduled day, the first step checks if the day falls on a working day as per the work calendar. If the day is not a working day then the stream ends execution ensuring stream runs only on desired dates.

Job streams that check existence of a file

In situations where a job stream needs to check if a file has been uploaded/created by another process before it can continue with rest of it’s processing, a special batch program “K1-OSCFE” is available. A step can be introduced referring to this new batch program with parameter specifying which object storage bucket to check the file in and also status to return if the file does not exist. This step can be added right before the step that has dependency on checking the existence of the file and continue processing or not.

Handling job streams inter-dependencies

In situations where a job stream should not run when another stream is running, the inter-dependencies between such job streams can be configured by using a special batch program “K1-CKCCR”. Following steps are needed to setup such configuration.
  • The new batch program accepts two parameters script name and script data. Write a CM script that checks whether a dependent job stream is running. If it’s running, then the script should terminate with an error.

  • On the batch job stream that needs to be paused/hold if another batch job stream is running, add a new step as the first step of the job stream. Use the new batch program on the first step(by setting the CM script as the input parameter) or create a scheduler program if the batch control is to be used across many job streams with different CM service scripts as input parameters. Set the dependent job stream name as the script data parameter.
  • Update the "End Of Stream" step condition such that if first step has failed, end the stream. This ensures the batch job stream does not run if the other dependent job stream is already running.
  • Update the step(s) intended to execute after the first step, the step condition that if first step succeeded only then these steps should continue.

Note. The special batch program is not restricted to only these situations. It can be used in many custom scenarios by writing the corresponding CM script that terminates if a desired situation is met.