JCL Interview Questions
JCL is Job Control Language and is used for Batch processing. The startup procedures of OS and standard products like CICS etc are written in JCL. It is interface between operating system(MVS) & application program. when 2 related programs are combined together on control statements is called job control language
A keyword in a JCL statement may appear in different places and is recognized by its name, eg. MSGCLASS in the JOB statement.
JES3 allocates datasets for all the steps before the job is scheduled. In JES2, allocation of datasets required by a step are done only just before the step executes
JOB - indicates start of jobstream to the operating system and through parms coded on it, certain details about the job (time, region, message level, job accounting data).
EXEC – indicates the start of execution of a particular job step, be that step a program or a proc.
DD - is a data definition, which is used to describe the attributes of a data set (name, unit, type, space, disposition).
The JOB statement is the first in a JCL stream. Its format is // jobname, keyword JOB, accounting information in brackets and keywords, MSGCLASS, MSGLEVEL, NOTIFIY, CLASS, etc.
The EXEC statement identifies the program to be executed via a PGM= program name keyword. Its format is //jobname EXEC PGM= program name. The PARM= keyword can be used to pass external values to the executing program.
The DD statement links the external dataset name (DSN) to the DDNAME coded within the executing program. It links the file names within the program code to the file names know to the MVS operating system. The syntax is // ddname DD DSN=dataset name. Other keywords after DSN are DISP, DCB, SPACE, etc.
First any private libraries as specified in the STEPLIB or JOBLIB, then the system libraries such as SYS1.LINKLIB. The system libraries are specified in the link list.
The comment statement is //* followed by the comments.
JOB(one per jobstream) EXEC(one or more per job) DD(one or more per jobstep)
Some of the JCL statements which are not allowed in procedures are:
1. JOB, Delimiter(/*), or Null statements
2. JOBLIB or JOBCAT DD statements
3. DD * or DATA statements
4. Any JES2 or JES3 control statements
Multiple jobs are submitted (as many jobs as the number of JOB cards).
JOB : Identifies a job and supplies accounting info
EXEC : Identifies a job step by indicating the name of the program to be executed.
DD : Identifies a data set to be allocated for the job step
Delimiter(/*) : Marks the end of an in-stream dataset
Null(//) : Marks the end of a job
Comments(//*) : Provides Comments
PROC : Marks the beginning of a procedure
PEND : Marks the end of a procedure
OUTPUT : Supplies options for SYSOUT processing.
A dataset is passed from one step to another based on what is coded on the DISP parameter. The dataset can only be passed to subsequent steps if PASS was used on the disposition parameter.
The space allocated when the dataset is first created.
Secondary allocation is done when more space is required than what has already been allocated.
Specifies that the private library (or libraries) specified should be searched before the default system libraries in order to locate a program to be executed. STEPLIB applies only to the particular step, JOBLIB to all steps in the job.
16 extents on a volume for a sequential file and 123 for a VSAM file.
A model dataset label is a pattern for the dataset label created for any dataset named as a part of the GDG group. The system needs an existing dataset to serve as a model to supply the DCB parameters for the generation data group one wishes to create. The model dataset label must be cataloged. The model DSCB name is placed on the DCB parameter on the DD statement that creates the generation data group.
The JOBLIB statement is placed after the JOB statement and is effective for all job steps. It cannot be placed in a cataloged procedure. The STEPLIB statement is placed after the EXEC statement and is effective for that job step only. Unlike the JOBLIB statement, the STEPLIB can be placed in a cataloged procedure.
JOBLIB is ignored.
The library with the largest block size should be the first one.
//ABCD JCLLIB ORDER=(ME.MYPROCLIB,SYS1.PROCLIB)
To override the REGION defined at the JOB card level. REGION specifies the max region size. REGION=0K or 0M or omitting REGION means no limit will be applied.
TIME parameter can be used to overcome S322 abends for programs that genuinely need more CPU time. TIME=1440 means no CPU time limit is to be applied to this step.
Means execute this step even if any of the previous steps, terminated abnormally.
Means execute this step only if any of the previous steps, terminated abnormally.
TYPERUN=SCAN on the JOB card or use JSCAN.
One way is to code SYSIN DD DUMMY in the PROC, and then override this from the JCL with instream data.
REGION specifies the maximum CPU memory allocated for a particular job or job step. If REGION is in the JOB card, it relates to the entire job; if in the EXEC statement, it relates to the job step.
TIME specifies the maximum CPU time allocated for a particular job or job step. If TIME is in the JOB card, it relates to the entire job; if in the EXEC statement, it relates to the job step.
Use IF ABEND statement in the JCL.
RESTART is a JOB statement keyword. It is used to restart the job at a specified step rather than at the beginning.
COND specifies the conditions for executing the subsequent job step. The value after the COND= is compared to the return codes of the preceding steps and if the comparison is true, the step is bypassed.
MVS now allows for an IF bracketed by an END IF around any job step to replace the COND= syntax. Again, if the IF statement is true, the step is bypassed.
The value after the PARM= specifies control information to be passed to the executing program of the job step.
COND is a condition parameter, consists of 2 sub parameters, 1st - return code from the previous step, 2nd - condition. If COND is true, the step on which COND is coded will be BYPASSED.
typrun=scan checks the JCL for errors, typrun=hold holds the job until further notice.
COND means condition parameter. It is compared with system return code of previous step.
//step1 exec pgm=abcd //step2 exec pgm=xyz, cond=(4,lt)
step2 will be executed when system return code of step1 is less than 4.
Time, Region and Cond parameters
Use RESTART=step name.
There are two position parameters in job statement.
By using 'parm' parameter in exec statement. The value mentioned here should be declared in linkage section in the program and process thru procedure division. This technique is very useful when you do not know the parameters at the time of coding the programs.
That this is a new dataset and needs to be allocated, to CATLG the dataset if the step is successful and to delete the dataset if the step abends.
That this is a new dataset and needs to be allocated, to CATLG the dataset if the step is successful and to KEEP but not CATLG the dataset if the step abends. Thus if the step abends, the dataset would not be catalogued and we would need to supply the vol. ser the next time we refer to it.
Need to supply Volume Serial Number VOL=SER=xxxx.
The MOD will cause the dataset to be created (if it does not exist), and then the two DELETEs will cause the dataset to be deleted whether the step abends or not. This disposition is used to clear out a dataset at the beginning of a job.
Datasets are concatenated by writing a normal DD statement for the first dataset and then adding a DD statement without a DDNAME for each dataset to be concatenated in the order they are to be read. The following is an example of three datasets concatenated:
//YEARDAT DD DSN=JAN.DATA,DISP=SHR // DD DSN=FEB.DATA,DISP=SHR // DD DSN=MAR.DATA,DISP=SHR
Unless allocated earlier, will have the following parameters: DISP=(NEW,CATLG,DELETE), UNIT , SPACE & DCB
Specify the parameter RLSE ( release ) in the SPACE e.g. SPACE=(CYL,(50,50),RLSE)
This is a new file and create it, if the step terminates normally, pass it to the subsequent steps and if step abends, delete it. This dataset will not exist beyond the JCL.
Temporary datasets can be created either by not specifying any DSNAME or by specifying the temporary file indicator as in DSN=&&TEMP. We use them to carry the output of one step to another step in the same job. The dataset will not be retained once the job completes.
PS - QSAM, PO - Partitioned, IS - ISAM
DISP=OLD denotes exclusive control of the dataset; DISP=SHR means there is no exclusivity.
DISP=MOD is used when the dataset can be extended, ie, you can add records at the end of an existing dataset.
The keywords associated with the DCB parameter are LRECL, RECFM, BLKSIZE and DSORG. The DCB information can be supplied in the DD statement. The system looks for DCB information in the program code first.
DCB stands for data control block; it is a keyword for the DD statement used to describe datasets. Keywords associated with it are BLKSIZE, DEN, LRECL and RECFM.
LRECL is the logical record length , where as BLKSIZE is multiples of LRECL
OLD specifies exclusive use of a dataset, SHR allows multiple jobs to concurrently access the dataset Note: When updating a dataset, you would normally use OLD.
There are three(3) parameters. Parameter 1: current data set disposition(new, shr, old, mod) Parameter 2: normal close action for data set (catlg, keep, delete) Parameter 3:abend action for data set (catlg, keep, delete).
SPACE=(n,m) for a sequential file, SPACE=(n,m,p) for a PDS where n, m, and p are numbers. The p designates how many directory blocks to allocate.
DISP=MOD is used to either extend an existing sequential dataset or to create a dataset if it does not exist. If the dataset exists, then records are appended to the dataset at the end of the existing dataset. If the dataset does not exist, the system treats MOD as if it were MOD can be used to add to a dataset that extends onto several volumes. Always specify a disposition of CATLG with MOD for cataloged datasets, even if they are already cataloged, so that any additional volume serial numbers will be recorded in the catalog.
A set of preceded JCL that can be modified through the use of parameters or override cards. Note: Procedures can be catalogued or instream.
PROC stands for procedure. It is 'canned' JCL invoked by a PROC statement. An instream PROC is presented within the JCL; a catalogued PROC is referenced from a proclib partitioned dataset
In job card, specify RESTART=PROCSTEP.STEPNAME where PROCSTEP = name of the JCL step that invoked the PROC and STEPNAME = name of the PROC step where you want execution to start
Provide the override on the EXEC stmt in the JCL as follows:
//STEP001 EXEC procname, COND.stepname=value
All parameters on an EXEC stmt in the proc such as COND, PARM have to be overridden like this.
In Stream procedures are set of JCL statements written between JOB and EXEC statements, start with PROC and end with PEND statement. Mainly used to test cataloged procedures. Cataloged procedure is cataloged on the procedure library and is called by specifying the procedure name on the EXEC statement.
A symbolic is a PROC placeholder; the value for the symbolic is supplied when the PROC is invoked, eg. &symbol=value. An override replaces the PROC's statement with another one; it substitutes for the entire statement.
I did not know the answer and my interviewer said NO. Later I tried and executed PROC from a PROC, three levels deep. Manuals do not state any limit on PROC calling PROC, or nesting.
Can use either condition codes or use the jcl control statement IF
Used to copy one QSAM file to another. Source dataset should be described using SYSUT1 ddname. Destination dataset should be described using SYSUT2. IEBGENR can also do some reformatting of data by supplying control cards via SYSIN.
IEBGENER -- This is a dataset utility for copying sequential datasets which produces a PDS or a member from a sequential dataset.
IEBCOPY -- This is a dataset utility for copying one PDS to another or to merge PDSs.
REPRO -- This is for copying sequential datasets. More or less same as the IEBGENER.
IEFBR14 is a Dummy utility and it is used for the sake of EXEC PGM= .... statement in JCL[when used it wouldn't perform any task]. e.g. While Allocating a dataset you don't have to run any utility [this could be done by giving disp=new inDD statement]. But for a PGM name must be given in EXEC statement, it is used.
Generation Data Group is a group of chronologically or functionally related datasets. GDGs are processed periodically, often by adding a new generation, retaining previous generations, and sometimes discarding the oldest generation.
GDG - group of dataset that are logically or chronologically related, referred by name and a relative generation number - an integer which identifies the generation of a dataset and is coded in parentheses after dataset name. Absolute GDG name - GxxxxVyy, where xxxx-absolute gen. number, yy-version number. Can be sequential, direct, partitioned. (VSAM - no). Must always be cataloged.
A GDG base is created in the system catalog and keeps track of the generation numbers used for datasets in the group. IDCAMS utility is used to define the GDG base.
Generation Data Groups are concatenated by specifying each dataset name and the generation number for all generations of the generation data group. Otherwise to have all generations of a generation data group, omit the generation number. The DD statement will refer to all generations. The result is the same as if all individual datasets were concatenated. If generations are not on the same volume, this will not work.
No, You can’t edit or browse the GDG if it resides on tape.
A new GDG is coded as (+1) after the dataset name as follows: DSN=JAN.DATA(+1). This will cause all generations to be pushed down one level at the end of the job.
Operation exception error For e.g. a dataset open error
Caused by invalid data in a numeric field.
Storage violation error - can be due to various reasons. e.g.: READING a file that is not open, invalid address referenced due to subscript error.
This error is faced when we execute the COBOL program. The main reason for this error is that a variable is defined with less characters and we are trying to move data which is larger than the actual storage space.
All indicate dataset out of space. SD37 - no secondary allocation was specified. SB37 - end of vol. and no further volumes specified. SE37 - Max. of 16 extents already allocated.
Indicates a time out abend. Your program has taken more CPU time than the default limit for the job class
S0C1-May be due to
1.Missing or misspelled DD name 2.Read/Write to unopened dataset 3.Read to dataset opened output 4.Write to dataset opened input 5.Called subprogram not found
S0C4-may be due to
1.Missing Select statement(during compile) 2.Bad Subscript/index 3.Protection Exception 4.Missing parameters on called subprogram 5.Read/Write to unopened file 6.Move data from/to unopened file
S0C5-May be due to
1.Bad Subscript/index 2.Closing an unopened dataset 3.Bad exit from a perform 4.Access to I/O area(FD) before read
S0C7-may be due to
1.Numeric operation on non-numeric data 2.Un-initialize working-storage 3.Coding past the maximum allowed sub script
S0CB-may be due to
1.Division by Zero
Pass all the jcl codes to a COBOL variable (should be declare using OCCURS clause) and the write the line one by one to the spool using CICS commands like SPOOL Close SPOOL Open SPOOL Write .
Code the DSN as PDS (member) with a DISP = SHR. The DISP applies to the PDS and not to a specific member.
//SYSIN DD* input data input data /*
Datasets can be grouped in a DD statement one after another, eg. in a JOBLIB statement where the load module can exist in one of many datasets.
Data definition name is the eight character designation after the // of the DD statement. It matches the internal name specified in the steps executing program. In COBOL that's the name specified after the ASSIGN in the SELECT ASSIGN statement. Dataset name is the operating system (MVS) name for the file.
For an output file DUMMY specifies that the output is to be discarded. For input it specifies that the file is empty.
Job will fall through to the ENDIF (not executing any steps), then resume execution with the first step AFTER the // ENDIF.
A control card can be a member of a pds or a sequential dataset and is used for storing the date fields, Definitions of VSAM files....etc. You use control card because you cannot use a instream procedure in a procedure. Generally you will be calling a Proc from your Jcl and you cannot code instream procedure in the Proc and so you will point to the dataset which is called control card.
By specifying the DISP as PASS for the temp dataset
The code is : //*MAIN DEADLINE=(0700,B,012099)
An include statement identifies a member of a pds or pdse that contains. This set of JCL statements is called an include group. The system replaces the include statement with the statements in the include group
It is 32,760.Based on that we can calculate efficient number of Records in a Block
This is managed by JES. This is used for Queuing the Outputs that are intended for Printing and are first stored in SPOOLDASD.
One block constitutes 32KB of formatted memory/ 42KB of Unformatted memory,6 blocks makes one Track & 15 Tracks makes one cylinder.