6. Examples
To help you feel more comfortable using PJS, this chapter presents several common scheduling problems and solutions:
· Section 6.1, How to Run a One‑Time Job, shows how to issue a job request for a job that PJS will submit once. Minimal specifications and accepted defaults are discussed.
· Section 6.2, How to Run a Daily Job, shows how to issue a job request for a job that PJS will submit every day. Frequency option issues are discussed.
· Section 6.3, How to Run a Job on the First Tuesday of Each Month, shows how to specify a PJS calendar and specify the calendar in a job request.
· Section 6.4, How to Run a Job That Depends on Another Job, shows how an event can solve certain types of scheduling problems. Job dependency factors and the PJSPOST JCL step are discussed.
· Section 6.5, How to Set Up Several Dependent Jobs, shows how to use events in an environment where several job dependencies exist.
· Section 6.6, How to Run a Job Whenever CICS Terminates, shows how you can use an event on the system level.
· Section 6.7, How to Run a Weekly Job After a Daily Job, shows how non‑preposted events can be used to solve certain types of scheduling problems. The rest of this chapter assumes that events are preposted.
· Section 6.8, How to Run a Job After a Manual Operation, shows how PJS/TSO commands or PJS/ISPF panels can be used to post an event. The rest of this chapter assumes that events are posted by the PJSPOST JCL step.
· Section 6.9, How to Reset an Event, shows how PJS/TSO commands or PJS/ISPF panels can be used to reset an event.
· Section 6.10, How to Enable a Failed Job Request, shows how you can deal with a job request that specifies a job that PJS cannot submit.
If you are new to PJS, it's a good idea to read this chapter from start to finish. Many of the examples assume that you know how to use PJS features illustrated in previous examples. Later, as you become familiar with PJS, you will be able to refer to the specific examples you need.
PJS/TSO commands are used in the examples. All PJS/TSO commands can be replicated on PJS/ISPF panels.
Suppose you want to submit a job at 3:00 AM tomorrow morning. You can use the following command to create the job request:
|
pjreqadd dataset('qual.tso.data(myjob)') - |
The new job request has the following characteristics:
· The JCL data set name is QUAL.TSO.DATA(MYJOB). The enclosing quotes make this a fully qualified data set name.
· The date of submission is one day added to the current system date. The date is specified as a relative date.
· The time of submission is 3:00 AM, using an absolute time specification. Because a 24‑hour clock is assumed, you can specify this value as 3:00 or 3:00AM: PJS accepts either specification.
· No frequency option was specified, so PJS will submit the job only once.
· Because the job is only submitted once, you don't have to specify an End Date or End Time.
· Assuming that your site gives you a choice, a copy of job JCL was not saved on the PJS JCL Spool. At submission, the JCL is submitted from the JCL Data Set.
· No Time Window was specified, so there is no actual deadline for job submission. If the system is down at time of submission, the job will be submitted after the system comes up and the PJS System Task is started.
· No events or job request events are specified.
· The ENABLED default is accepted. The PJS System Task puts the new job request in WAIT status.
Suppose you want to submit a job every day at 6:00 AM You can use the following command to create the job request:
|
pjreqadd dataset('qual.tso.data(myjob)') save - |
The new job request has the following characteristics:
6.3 How to Run a Job on the First Tuesday of Each Month
Suppose you want PJS to submit a job on the first Tuesday of every month in 2003 at 6:00 PM. From MINUTES through YEARS, none of the periodic frequency options give you a way to specify the first Tuesday in every month. However, you can regard the first Tuesday of every month is an arbitrary set of dates. You can select arbitrary sets of dates in a PJS calendar, which must be specified before you can issue a job request that uses the calendar.
You can use the following command to create the PJS calendar:
|
pjcaladd firsttue dates(1/7/03
2/4/03 3/3/92 4/7/03 - |
The created calendar has the following characteristics:
After the calendar has been created, you can specify the calendar as the frequency option in a PJS job request:
|
pjreqadd dataset('qual.tso.data(myjob)') - |
PJS will now submit the job at 6:00 PM on each of the dates specified in the calendar.
6.4 How to Run a Job That Depends on Another Job
Suppose you want PJS to submit two jobs. JOB1 is to be submitted at 6:00 PM today, and JOB2 should be submitted after JOB1 finishes execution. You can approach this problem in a couple of ways:
First, make JOB1 post an event by adding the following step to the end of its JCL statements:
|
//JOB1 JOB . . . // existing JCL statements // . // . // . //PJSPOST EXEC PGM=PJSPOST,PARM='USER01.JOB1END' |
The new job step has the following characteristics:
Next, create a job request to run JOB1:
|
pjreqadd dataset('qual.tso.data(job1)') - |
Finally, create a job request to run JOB2:
|
pjreqadd dataset('qual.tso.data(job2)') - |
PJS will submit JOB1 at 6:00 PM. JOB2 is also scheduled to run at 6:00 PM, but it also has an event (JOB1END) that must be posted before it will be submitted. This event is posted by the last step of JOB1. So when JOB1 completes, and the last step is run, the PJSPOST batch program will post the JOB1END event. PJS can then submit JOB2.
6.5 How to Set Up Several Dependent Jobs
Suppose you want to submit six jobs, and suppose you have the following constraints:
First, make all of the jobs post an event by adding the following step to the end of each job:
|
//JOBn JOB . . . // existing JCL statements // . // . // . //PJSPOST EXEC PGM=PJSPOST,PARM='USER01.JOBnEND' |
In each job, n is the number of the job. (The actual job names and event names are not significant. These names are used for clarity.)
After all six jobs are modified, issue a job request for each job:
|
pjreqadd
dataset('qual.tso.data(job1)') -
pjreqadd
dataset('qual.tso.data(job2)') -
pjreqadd
dataset('qual.tso.data(job3)') -
pjreqadd
dataset('qual.tso.data(job4)') -
pjreqadd
dataset('qual.tso.data(job5)') -
pjreqadd
dataset('qual.tso.data(job6)') - |
After creating these job requests:
6.6 How to Run a Job Whenever CICS Terminates
Suppose you want PJS to submit a job whenever CICS terminates. You can consider CICS termination an event, just you do with a batch job. However, this will probably require the assistance of the CICS system programmer, and may also require the assistance of the PJS administrator.
Add the PJSPOST job step to the end of the CICS Task (this will probably have to be done by the CICS system programmer):
|
//CICS PROC . . . // existing CICS procedure // . // . // . //PJSPOST EXEC PGM=PJSPOST,PARM='CICSA.CICSEND', // COND=EVEN |
Note that the event‑ID uses an owner‑ID of CICSA. (The exact name is not important.) This name is used instead of your own TSO user-ID so that others can also use the same event.
Also, the jobstep includes the COND=EVEN JCL parameter to ensure that the post runs even if CICS abends. You may wish to consider if this is appropriate for your application.
Then create the job request:
|
pjreqadd dataset('qual.tso.data(myjob)') - |
This new job request is scheduled to run once a minute, starting just one minute from now! But, since the job request also waits on an event, it has the effect of running the job request whenever the event is posted. The time of day is not significant.
When you specify the event‑ID, you must include the owner‑ID (CICSA), since it is different than your TSO user-ID. To do this you may need your PJS site administrator to change the site security to allow you to do this. Also the site security policy must allow the CICS Task to post the PJS event.
6.7 How to Run a Weekly Job After a Daily Job
Suppose you want to submit two jobs. JOB1 is to be submitted Monday through Friday at 6:00 PM JOB2 is to be submitted only on Friday and only after JOB1 finishes.
First, make JOB1 post an event by adding the following step to the end of its JCL statements:
|
//JOB1 JOB . . . // existing JCL statements // . // . // . //PJSPOST EXEC PGM=PJSPOST,PARM='USER01.JOB1END' |
Next, issue a job request for JOB1:
|
pjreqadd dataset('qual.tso.data(job1)') - |
Finally, issue a job request for JOB2.
|
pjreqadd dataset('qual.tso.data(job2)') - |
JOB1 is scheduled to run every Monday through Friday at 6:00 PM. JOB2 is scheduled to run every Friday, also at 6:00 PM
The EVENT parameter is used to require that JOB2 wait for JOB1 to finish. However, JOB1 runs and posts the event every Monday, Tuesday, Wednesday, and Thursday, as well as Friday. Without the /NOPREPOST option, JOB2 will run on Friday at 6:00 PM, without waiting for JOB1 can finish, because the event was posted earlier in the week. The event normally is not reset in the job request for JOB2 until JOB2 is submitted.
The /NOPREPOST option for event posting means that PJS cannot post the job request event before the Next Run Date and Time. Since JOB2 is not scheduled to run until Friday at 6:00 PM, the job request event will not posted when JOB1 runs on Monday through Thursday. However, when JOB1 runs on Friday (which will be after the 6:00 PM scheduled run time for JOB2) the job request event will be posted, and JOB2 will be submitted.
6.8 How to Run a Job After a Manual Operation
Suppose that you, USER01, want to submit a long job after your colleague, USER02, leaves for the day. You can define an event that USER02 can post before leaving.
Assuming you are authorized, you can use the following command to create the job request:
|
pjreqadd dataset('qual.tso.data(myjob)') - |
Then, before leaving, USER02 can use the following command to post the event:
|
pjevpost imgone |
The event will be posted and the job will be submitted at 5:00 PM. If it is already past 5:00 PM the job will be submitted (almost) immediately.
Suppose that you, USER01, want to submit a long job after your colleague, USER02, leaves for the day. You can use the procedure detailed in Section 6.8.
First, you can issue the following job request:
|
pjreqadd dataset('qual.tso.data(myjob)') - time(17:00) - event(user02.imgone) |
Then, USER02 can post the event:
|
pjevpost imgone |
Suppose that USER02 returns to the office before the 5:00 PM runtime for the job. The condition for job submission was USER02's absence. USER02, realizing this, can issue the following command:
|
pjevrset imgone |
The event is reset, and posting is removed from the event and related job request events. If this command is issued before PJS submits the job, the job is not submitted.
6.10 How to Enable a Failed Job Request
Suppose you issue two job requests, and make JOB2 dependent on JOB1. Now, suppose that the job JCL for JOB2 was accidentally deleted after the job requests were added but before the jobs were submitted.
When JOB1 completes, the USER01.JOB1END event is posted. The PJS System task then tries to submit JOB2, but fails. The PJS System Task sends an error message to the user.
Assuming that the request‑ID is USER01.002, you can use the following command to check job request status:
|
pjreqlst id(2) detail |
This command generates the following display:
|
Next Run Window Last Submit Request-ID Status Date Time Time Option Date Time USER01.002 ERROR 09/10/1991 18:00 09/10/91 8:31:57
JCL Data Set Name Save QUAL.TSO.DATA(JOB2) NOSAVE
Start End Frequency Date Time Date Time ONCE 09/10/1991 18:00
Pre- Posted Event-ID Post Date Time USER01.JOB1END YES 09/10/1991 18:31:56 |
You see that the job request was placed in ERROR status. The error messages and a little bit of exploration reveal the cause of submission failure. To fix the job request, you can:
After you fix the problem, you need to enable the job request:
|
premed 2 enable |
The job request status will change to WAIT. In this case, if nothing else is changed, the job will be submitted (almost) immediately, since the Next Run Date and Time is in the past and all job request events are still posted. If this is not appropriate then the STARTDATE and STARTTIME parameters should be used to change the Next Run Date and Time, or the RESETEVENTS parameter should be used to reset the job request events before enabling the job request.
Copyright © Northrop Grumman, 1990, 2004. All rights reserved.