JCL interview questions

Q. How are datasets concatenated?
A. Datasets can be Concatenated with the DD statement. The first dataset is written as a normal DD statement. The remaining DD statements will not have DDNAME.
Example:
//DD1 DD DSN=EXAMPLE.DATASET1,DISP=SHR
// DD DSN=EXAMPLE.DATASET2,DISP=SHR

The GDGs also can be concatenated as shown above by listing all the generations. Alternately we can code just one DD statement by giving the GDG base name in the DSN.

Q. How do you refer the latest version of GDG file

A. We can access the latest version of GDG by referring (0) version.
//DD1 DD DSN=EXAMPLE.DATASET1(0),DISP=SHR

Q. How do you refer the GDG dataset created in the previous step in the same job.

A. You can access the GDG from previous step in the same job by referring (+1) generation and DISP=SHR

Example Lets say the below GDG version is created in STEP010.
//DD1 DD DSN=EXAMPLE.DATASET1(+1),DISP=NEW
…..
…..

In the next step the above dataset can be accessed as below.

//DD1 DD DSN=EXAMPLE.DATASET1(+1),DISP=SHR

Q. Can Instream data be given in PROC?
A. No.

Q. How do you create a GDG base in JCL
A. GDG base can be created using IDCAMS utility.

Q. Explain JCLLIB in JCL
A. JCLLIB specifies the library where the procedures can be found.

Q. Explain JOBLIB and STEPLIB in JCL
JOBLIB specifies the private library where the load modules can be found before searching the default system libraries. JOBLIB is coded after the JOB statement. JOBLIB is at JOB level JOBLIB library applies for entire job.
STEPLIB also specifies the private load module library but is at step level. STEPLIB scope is limited to the step where it is coded.
If both JOBLIB and STEPLIB are coded in the job STEPLIB overwrites the JOBLIB.

Q. What is the maximum number of secondary extents allowed in SPACE parameter in JCL.
A. 15.

Q. Explain primary and secondary extents in SPACE parameter in JCL.
A. Example: SPACE=(CYL,(100,50),RLSE)
100 cylinders will be allocated at the beginning to the dataset then 50 cylinders per each extent will be allocated up to 15 extents. RLSE command releases the unused space after the dataset is created.

Q. How many tracks are there on one cylinder space in JCL.
A. 15.

Q. What is temporary dataset. How is temporary dataset created
A. Temporary datasets are created when we do not want to retain the dataset after the job is completed but want to pass the datasets from one step to another step.
To create a temporary dataset we give:
DSN=&&TEMP
No DSNAME should be specified.

Q. Explain RESTART parameter in JCL.
A. RESTART parameter is coded in the JOB statement to restart the job from a particular step.
RESTART=STEPNAME
If the RESTART step is in a PROC then
RESTART=JOBSTEP.PROCSTEP

Q. Explain COND parameter in JCL
A. COND parameter in JCL is used to skip any steps in the JOB. COND parameter can be give at JOB level and STEP level.

COND=(return code, EQ or LE or LT or GT or GE)
If the condition is true then the step will be skipped.
EQ = equal
LE = Less than or equal
LT = Less than
GT = Greater than
GE = Greater than or equal.

COND=EVEN

If COND=EVEN is coded then the steps will be executed even if any of the previous steps abended.

COND=ONLY

If COND=ONLY is coded then the steps will be executed only when any of the previous steps abended.

Example:
STEP010 EXEC PGM=IEFBR14,
COND=(6,LE)

In the above example STEP010 is executed only when the condition is not matched. i.e. the step will be skipped only when return code from the previous steps is > 6.

Q. How do you find the syntax errors in a JCL without running the job
A. We can give TYPRUN=SCAN in the JOB statement and submit the job. It will not run the job but gives you all the syntax errors.

Q. Explain PARM parameter in JCL
A. PARM parameter is used to pass the data to application program from JCL. We code it in the EXEC statement.
PARM=parameters to be passed
The maximum length of the parameters that can be passed through PARM is 100.
The parameters passed through the JCL needs to be handled in the receiving COBOL program.

Q. What is the maximum number of steps that can be coded in a JCL
A. 255.

Q. What is the maximum number of instream procedures that can be coded in a JCL
A. 15.

Q. Explain TYPRUN parameter in JCL.
A. TYPRUN parameters can be used in two ways.
TYPRUN=SCAN
TYPRUN=HOLD

TYPRUN=SCAN checks for the syntax errors without running the job.
TYPRUN=HOLD holds the job without running.
Q. Explain IEBGENER utility in JCL
A. IEBGENER utility is mainly used to copy datasets. IEBGENER can also be used for creating datasets, change the LRECL and Block size of the datasets.

Example to copy datasets using IEBGENER:

//STEP001 EXEC PGM=IEBGENER
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=EXAMPLE.FROM.DATASET,DISP=SHR
//SYSUT2 DD DSN=EXAMPLE.TO.DATASET,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(100,50),RLSE),
// DCB=(RECFM=FB,DSORG=PS,LRECL=80)

Q. Explain IEFBR14 utility in JCL
A. IEFBR14 is an utility used to create and delete datasets.

Example to delete a dataset:

//STEP001 EXEC PGM=IEFBR14
//DD1 DD DSN=EXAMPLE.DELETE.FNAME,
// DISP=(MOD,DELETE,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(1,1))

Example to create a dataset:

//STEP001 EXEC PGM=IEFBR14
//DD1 DD DSN=EXAMPLE.CREATE.FNAME,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(100,50),RLSE),
// DCB=(RECFM=FB,DSORG=PS,LRECL=80)

In the above example we can give DSORG=PO to create a partitioned dataset.

Q. Explain IDCAMS utility in JCL.
A. IDCAMS Can be used for various purposes:

– Copy VSAM and NON VSAM Datasets (REPRO)
– Create GDG
– Delete GDG
– Create VSAM dataset (Define Cluster)
– To create and Alternate Index File (AIX)
– To define a path for and AIX file
– To populate the records in the indexed file or AIX
– To LISTCAT

Q. How to create GDG base using IDCAMS
A.
//STEP001 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE GDG (NAME(EXAMPLE.TEST.GDGBASE) –
NOEMPTY SCRATCH LIMIT(20) )
/*
//*

Q. How do you indicate the end of insteream data in JCL?
A. code /* in the first 2 columns.

Q. Explain MSGCLASS parameter in JCL.
A. MSGCLASS specifies the output devise to which the messages are printed.
MSGCLASS can take values from A thru Z and 0 to 9.

Q. Explain MSGLEVEL parameter in JCL.
A. MSGLEVEL lets the JOB know which statements needs to be printed.

MSGLEVEL(stmt,msg)
The values for statements can be 0,1,2. The values for messages can be 0,1

Statements:
0 – Job related statements are printed.
1 – Expanded job statements are printed.
2 – Job input statements are printed.

Messages:
0 – Messages are printed only when the job abends
1 – Messages are printed both times when job abends or successfully completes.

Q. Explain JCL SORT utility.
A.
JCL SYNCSORT:

SYNCSORT utility in JCL is used to sort the datasets, merge datasets and copy datasets. Most of the installations change the SYNCSORT utility program name to SORT.

SORT Statement format:

SORT FIELDS = (Starting position, Length, Format, Asc/Des, { Starting position, Length, Format, Asc/Des}{…..})

OR

SORT FIELDS = (Starting position, Length, Asc/Des, { Starting position, Length, Asc/Des}{…..}),{Format}

Starting position indicates the location of the sort key in the record.
Length indicates the length of the sort key.
Format indicates the field type which can have values CH – Character, ZD – Zonal Decimal, PD – Packed Decimal and BI – Binary.

Asc/Des indicates order of the sort Ascending / Descending.

Examples:
SORT FIELDS = (1,3,CH,A)
SORT FIELDS = (1,5,D),CH

SUM FIELDS = NONE option eliminate duplicates.

Ex: SORT FIELDS = (1,5,D),CH
SUM FIELDS = NONE

SKIPREC and STOPAFT parameters
SKIPREC = n statement skips n records before copy or sort.

SORT FIELDS = COPY
SKIPREC = 1000

The above statement skips first 1000 records and copies remaining records.

STOPAFT = n statement copies or sorts at most n records.
SORT FIELDS = COPY
STOPAFT = 1000

The above statement outputs first 1000 records after any processing is done.

MERGE can be used to merge two or more pre sorted datasets. We can merge a maximum of 32 datasets.

MERGE Statement format:

MERGE FIELDS = (Starting position, Length, Format, Asc/Des, { Starting position, Length, Format, Asc/Des}{…..})

OR
MERGE FIELDS = (Starting position, Length, Asc/Des, { Starting position, Length, Asc/Des}{…..}),{Format}

INCLUDE COND:
Include statement can be used to include records based on a specific condition.

INCLUDE COND = (Starting position, Length, condition operator, value)

Example:
SORT FIELDS = COPY
INCLUDE COND = (1,3,EQ,’JCL’)
In the above examples the records which contain ‘JCL’ in the first 3 positions are copied.

OMIT COND:
Similarly we can omit the records from the dataset based on a specific condition.

SORT FIELDS = COPY
OMIT COND = (1,3,EQ,’JCL’)

In the above examples the records which contain ‘JCL’ in the first 3 positions are not copied.