Friday 10 August 2012

JCL procedure


                                            What is JCL Procedure?

In JCL code reusability function is JCL procedure. A copy of JCL code like dataset creation, copy a dataset etc. Operation will perform on daily routine so every time instead of copying a same code and submitting the code we can use JCL procedure.
Here you just call the code in your main program so no need to submit seprate.
E.g. Suppose there is 2 different job which reads same dataset so instead of writing a seprate code for each job what i do is i will write a JCL code to read a dataset in the form of Procedure\PROC and  call that PROC in that 2 different job.

In short PROC is Same JCL used by multiple users in there program.

                                         What are the Types of JCL PROC?

There are two types of JCL Proc.

    1) Instream Procedure 
     2) Catlog procedure.

                                        What is Instream procedure?

1               1) In Instream procedure we write a procedure code in  JCL  code itself. 
                    2)No separate calling for another PDS member.
       3)  Maximum 15 Instream Procs you can write in a JCL. 
       4)  You can refer the same Instream Proc in any step in same JCL.




                                       What is Catlog procedure?

     1)    Here you are calling a JCL code stored in another PDS member or in system library.


     2)    If you are using system library i.e. sys1.proclib which contains member like below snap shot.













 3)    If you have coded your JCL in your personal JCL then you must give the path for compiler to find out JCL code which you have called i.e your PROC code.

So to give a path you can use STEPLIB or JOBLIB parameter.



   
                                   What is STEPLIB and JOBLIB?

As a JOB contains several steps like step1, step2, step3 etc.
So in JOBLIB we describe the JCL which is common for all JOB steps for the particular JOB.
Suppose all the steps in JOB uses different procs but we are storing all procs in same PDS then we can give the path of that PDS and will tell the compiler that this is my JOB which contains following steps and for every step use same PDS to find out the PROC required to execute a step.


SYNTAX:
JCLLIB DD DSN=ak999.new.proc, DISP=SHR


This statement must write after JOB card and before any EXEC statement.



If we have a different PROC for each step also locate at different destination PDS then we must use STEPLIB in our program.

SYNTAX:


//STEPLIB DD  DSN=AK999.PROCLIB,DISP=SHR


STEPLIB must be coded after EXEC statement like below


//step1 exec pgm=myproc
//steplib dd dsn=ak999.proclib,disp=shr

                                    Can we code both STEPLIB and JOBLIB?


Yes you can. Here the system will search STEPLIB library first then system library. The system will ignore the JOBLIB library for the particular step where you defined STEPLIB DD statement.





Program:

 Now i have coded below CATLOGPC . This is my PROC name which i have coded in my personal PDS.
 personal PDS.





Do not use JOBCARD while defining a JCL PROC code.

Do not submit the PROC job.

Now i am calling above program in another JCL program.


Submit this job will create a new version of GDG through catlog procedure.





No comments:

Post a Comment