Joined: 02 Nov 2004 Posts: 18 Location: Noida, India
As per my knowledge, i don't think that it is possible to execute steps randomly in a JCL. Rather you have to execute it sequentially, and write in the manner you wnat them to be executed.
Joined: 06 Jan 2004 Posts: 247 Location: Hyderabad
It is always asked whether i can execute only odd/even steps of JCL or random steps etc. But it is not possible to do so in JCL. Restart parameter helps you if you need to start executing from certain steps and it is possible to bypass certain steps using COND parameter.
Quote:
I have 5 steps.I want to execute from 2nd step,then 1st,then 4th and then 3rd steps.Is it possible.can anyone clear my doubt.
Why dont you change your Job in that required manner?
[quote="anuradha"]It is always asked whether i can execute only odd/even steps of JCL or random steps etc. But it is not possible to do so in JCL. Restart parameter helps you if you need to start executing from certain steps and it is possible to bypass certain steps using COND parameter.
[quote]I have 5 steps.I want to execute from 2nd step,then 1st,then 4th and then 3rd steps.Is it possible.can anyone clear my doubt.[/quote]
Why dont you change your Job in that required manner?[/quote]
hello,
executing steps randomly by using DPART parames
second way is using IEBEDIT COMMAND.
Can you please describe clearly about the two methods you mentioned.[/quote]
hai anu
it can be solved by using the following two mehods
1. in step card u have to mention the dprty=(val1,val2)
priority=16*val1 +val2 according to result value step will be executed higher number higher priority
2. By using IEBEDIT u have to specify the name after sysin dd *
steps (step10 step2.....) in ur prefered manner
during runtime these r executed as mentioned manner
regs
veera
Joined: 06 Dec 2004 Posts: 211 Location: Keane Inc., Minneapolis USA.
Hey Man,
Try the following method. it may work efficiently.
Create a flat file using ISPF option 3.2 A and enter step numbers which u want to execute.
Eg: 2
5
7
12
and so on.... Then write a Cobol program which reads your source JCL and starts a Step_Counter as 0 ( a WS variable) for each step it is incremented by one. Compare present Step_Counter Value with The Step numbers available in Flat file. If match then copy that step ( read as record) into a new flat file ( will be your result JCL).
Repeat the process for all steps then either manually execute newly generated JCL file or automatically submit using (*,INTRDR) ( refer to previous faq for automatically submitting jcl from cobol).
If u have chance and patience you can create a tool with above specifications. Ok.
Joined: 06 Jan 2004 Posts: 247 Location: Hyderabad
Hi veera,
Where are you man. Why dont you provide the Sample JCl for the two methods which you suggested. But AFAIK coding DPRTY in the step level will just ignore that and i dont think it will give us the solution. But it is appreciable If you provide us the JCL if it works for you.
And one small suggestion from me. Why dont you preview your post before posting. Because i have seen many of your posts have the QUOTES but not in a fine way. and just dont say hello. It is very rude. Its only my suggestion.Hope you will take in a positive sense.
I coded JOB1 to have 5 steps that just write the stepname to a dataset as proof that the process is working. Here is the results from the dataset:
Code:
JOB JOB1 RAN STEP0002 <= START AT STEP2
JOB JOB1 RAN STEP0003
JOB JOB1 RAN STEP0004
JOB JOB1 RAN STEP0005
JOB JOB1 RAN STEP0001 <= START AT STEP1
JOB JOB1 RAN STEP0002
JOB JOB1 RAN STEP0003
JOB JOB1 RAN STEP0004
JOB JOB1 RAN STEP0005
JOB JOB1 RAN STEP0004 <= START AT STEP4
JOB JOB1 RAN STEP0005
JOB JOB1 RAN STEP0003 <= START AT STEP3
JOB JOB1 RAN STEP0004
JOB JOB1 RAN STEP0005
Joined: 06 Jan 2004 Posts: 247 Location: Hyderabad
Hi Kevin,
The job given by you is almost like starting particular job from particular step right!
And my doubt is can we use this utility to execute steps randomly in a selective way. Suppose i want to execute job1 in the following way:
Step2,step4,step1 and then execute step3.Is this possible. I dont think it is. Even i tried to do.But i couldn't. If it is possible please give us the jCL for this.
First create a simple program which will read a file and set the return code based on the file... Once the first record is read and return code is set it will then place a flag next to the first record that this step is executed... Afterwards when the program is again called it will check the first record and if there is there is flag it will skip that record and read the next record.... if there is no flag set in the second record it will set the second record content as the return code.....
i.e
Consider the following file as sample....
RETURNCODE STEP EXECUTED STATUS FLAG
----------------FILE START------------------------------------------
6 Y
3
11
----------------FILE END---------------------------------------------
Our jCL should be coded like this
step1
Execute the program which will read the input file and set the rc code as value of RETURNCODE field in the input file. Once the return code is genrated that record is marked as processed (Y)... If there all records were already processed the retun code is set to say 99
if rc=3
execute step3
if rc=6
execute step6
if rc=11
execute step3
if rc <> 99
last step ... submit the same job again through intr reader
So now the job will be submited 3 times as per our example.. and in the first run the program will read the input file and set the rc as 6 .. and it also sets the first records status flag as Y(inorder to skip the 6 step when the job is submitted again through the internal reader) Since the rc is set as 6 only the step 6 will be executed... and at end the last step will again submit the jcl..
When the jcl is submitted again the program is executed again, it has to skip the first record(step 6) since the flag is set as Y(already processed in run 1) and read the next reacord and set the rc as 3..Now only the step 3 will be executed and the whole process will be replicated untill the exit conditon is reached
NOTE : Please let me know if any body knows a better solution...
Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
Call me too curious, but has anyone actually ever had to run a job with the steps out of order or randomized other that restarting at a particular step?
This questions appears regularly on several MVS discussion boards and it sounds too much like an interview or classroom question.
I worked in a large insurance company IT shop as well as a large retailer IT shop and I never saw a production problem addressed by executing steps out of order. If a situation required unusual step order, a job was created containing them in the order required, placed in a special JOB library and operations notified that it was ready to execute.
Joined: 06 Jan 2004 Posts: 247 Location: Hyderabad
Yep Even I agree with you Dave. I bet these are Interview questions. Never we got this kind of situation. And am sure if we get also we go for another job rather than trying in the above ways.
Looking at this discussion, I tried different options with IEBEDIT
Below are my conclusions
1) We can not run steps in a random order using IEBEDIT but can be selective on the steps we need from other JCL's we call from the main JCL
i.e. Suppose you have two jobs A and B. If you call the second job(B) which has five steps and if we say like
TYPE=INCLUDE,STEPNAME=STEP2,STEP1,STEP4,STEP3 in the first Job =(A) then the order of step run will not be STEP2,STEP1,STEP4,STEP3 rather it will be STEP1,STEP2,STEP3,STEP4.
With the TYPE=INCLUDE statement we are only specifying the steps we need to include in the run and the order will be as it is in the second Job(B) that has these steps.
2) We can include steps from more than one Job including more than one EDIT statement, like
//SYSIN DD *
EDIT START=Job(B),TYPE=INCLUDE,STEPNAME=(STEP2,STEP1,STEP4)
EDIT START=Job(C),TYPE=INCLUDE,STEPNAME=(STEP8,STEP9,STEP6)
EDIT START=Job(D),TYPE=INCLUDE,STEPNAME=(STEP11,STEP14)
/*
3) When you say include more than one job like above, all the jobs will eventually be called and will be submitted for a run when you submit Job(A)
4) Another option for TYPE parameter above is TYPE=POSITION. When you say this, all the steps from the particuar step we mention in EDIT statement will be included for the run
Ex: EDIT START=Job(B),TYPE=POSITION,STEPNAME=STEP4
Suppose we have 5 steps in Job B. With the above statement ssteps 4 and 5 will be considered when Job B is called from Job A
5) I tried giving more than one step in TYPE=POSITION like below
EDIT START=Job(B),TYPE=POSITION,STEPNAME=(STEP4,STEP2,STEP3)
Job A returned a code of 4 and Job B went successfully with all the steps from step2 i.e step2, 3, 4 and 5 from Job B ran succesfully. But Job A returned a code of 4 saying invalid operand.
My conclusion here is that irrespective of any number of steps you give with TYPE=POSITION, all the steps from the versy first step mentioned in the EDIT list are considered and will run and the main Job will return a code of 4.
Please correct me if I'm wrong here.
Call me too curious, but has anyone actually ever had to run a job with the steps out of order or randomized other that restarting at a particular step?
This questions appears regularly on several MVS discussion boards and it sounds too much like an interview or classroom question.
I worked in a large insurance company IT shop as well as a large retailer IT shop and I never saw a production problem addressed by executing steps out of order. If a situation required unusual step order, a job was created containing them in the order required, placed in a special JOB library and operations notified that it was ready to execute.
Dave
I was thinking the same thing. And if a job is set up in such a way you'd want to run the steps randomly and out of order, most likely the steps aren't that closely relately and maybe the job could be broken up into smaller jobs and the schedule or the other jobs decide which to run next.
I haven't used those fancy tools like IEBEDIT but they look like they'll do for most of what these kinds of questions are asking to do.
I'm not claiming the following is better or should be used instead. Just posting to give ideas. These have been used for years. They have the advantage that you can use them even if you don't have access to the scheduler(they don't always just give that to everyone) and/or want to use them in a test environment in which you couldn't use a scheduler if you wanted to.
1. Use 2 condition codes. Say ODD and EVEN. Create a simple program that simple sets the condition code for ODD and EVEN. When you want to run the odd steps pass 1 to odd and 0 to even. This utility program is simple and just makes the condition code of the step = to whatever you made odd or even. Then in the cond parameter of each odd step you have to say something to the effect that if the CC of the utility step = the value of ODD, then do the step and vice versa for the even steps.
This method of using two condition codes will also enable you to start in a certain step and end in another. You could you CC1 to indicate the step you want to start in and CC2 to indicate the step you want to end in.
In this method you don't need to use RESTART.
2. Base the condition code of one step on the condition code of the previous so the odds don't run if the evens do. This can be tricky so you have to watch your condition codes. Or you can base the condition code of the rest of the job on just steps 1 and 2(2 has to be based on 1). For all of these you have to do a RESTART and start in either first odd or even step.
3. Since we're on the subject, another method I've seen used that I didn't like much at all was to base the restart on 'control datasets'. Basically, if the first REAL step in the job completed successfully, it creates a dataset conforming to conventions and having 'STEP010' in the desigated spot. This dataset is just and empty dataset made via iebgener using disp to keep it if the step finishes ok or delete it if not.
Then STEP020 creates a STEP020 dataset and deletes the STEP010 if it's successful or just leaves the STEP010 if not. Again just using iebgener and the disp parameter.
This continues all the way down until the last step of the job which doesn't create a control dataset but deletes the one from the previous step.
Then there is a utitlity that is the very first step in the job that looks for the existance of the control datasets and sets a condition code equal to the STEP part of the control dataset if one exists. Then each step in the job has a CC that says 'run me if my step is greater than the one that created that control dataset.