1. What is JCL?
o Answer: JCL (Job Control Language) is a scripting language
used on IBM mainframe operating systems (z/OS) to tell the
system what programs to run, what data sets to use, and how
to manage those resources for batch processing.
2. What are the three main statements in JCL?
o Answer: JOB, EXEC, and DD.
3. Explain the purpose of the JOB statement.
o Answer: The JOB statement is the first statement in a JCL job.
It identifies the job to the system, provides accounting
information (like account number), and specifies overall job-
level parameters (like job class and message class).
4. Explain the purpose of the EXEC statement.
o Answer: The EXEC statement specifies the program or
procedure that the system should execute in a particular step
of the job. It uses the PGM= parameter to name a program or
the PROC= parameter to name a cataloged or in-stream
procedure.
5. Explain the purpose of the DD statement.
o Answer: The DD (Data Definition) statement describes and
defines the data sets (files) that a job step will use. This
includes input files, output files, work files, and system output
streams.
6. What is a dataset in JCL?
o Answer: A dataset in JCL is a collection of related data
organized in a specific format, similar to a file in other
operating systems. It's identified by a Data Set Name (DSN).
7. What is the significance of the // symbol in JCL?
o Answer: The double forward slash (//) at the beginning of a line
indicates that it is a JCL statement.
8. What is the difference between a positional parameter and a
keyword parameter in JCL?
o Answer: Positional parameters must be specified in a
predefined order and are identified by their position within the
statement. Keyword parameters can appear in any order and
are identified by a keyword followed by an equal sign and a
value (e.g., CLASS=A, DSN=[Link]).
9. What is the purpose of the DSN parameter in a DD statement?
o Answer: The DSN (Data Set Name) parameter specifies the
name of the dataset that the DD statement is defining.
10. What is the purpose of the DISP parameter in a DD statement?
o Answer: The DISP (Disposition) parameter describes the
current status of the dataset and specifies what the system
should do with it at the end of the job step (normal and
abnormal termination). It has three subparameters:
(status,normal_termination,abnormal_termination).
For Experienced Professionals:
1. Explain the different values of the DISP parameter and their
implications.
o Answer: Common values include:
NEW: Creates a new dataset.
OLD: Specifies an existing dataset for exclusive access.
SHR: Specifies an existing dataset for shared read
access.
MOD: Specifies an existing sequential dataset to append
to.
CATLG: Catalogs the dataset in the system catalog.
UNCATLG: Removes the dataset's entry from the system
catalog.
KEEP: Retains the dataset after the job step.
DELETE: Deletes the dataset.
PASS: Passes the dataset to a subsequent step.
o The implications depend on the combination used, affecting
dataset creation, access, and retention.
2. How do you pass parameters to a program in JCL? Provide an
example.
o Answer: Parameters can be passed using the PARM= keyword
on the EXEC statement:
Code snippet
//STEP1 EXEC PGM=MYPROG,PARM='INPUT=FILEA,OUTPUT=FILEB'
The program MYPROG would then need to be coded to accept and parse
these parameters.
3. What is the purpose of the SYSOUT parameter in a DD statement?
Give examples of its usage.
o Answer: The SYSOUT parameter directs output to a system
output device or class (e.g., printer, job log).
SYSOUT=A: Sends output to the system printer (output
class 'A').
SYSOUT=*: Sends output to the job log.
SYSOUT=(E,INTRDR): Sends output to the internal reader
(for submitting another job).
4. Explain the concept of a Generation Data Group (GDG) and how you
would create and use one in JCL.
o Answer: A GDG is a collection of chronologically related
datasets managed as a group. A GDG base is created using
IDCAMS. New generations are created using
DSN=[Link](+1) with DISP=(NEW,CATLG,DELETE).
Existing generations are referenced using
DSN=[Link](0) (current), [Link](-1) (previous),
etc.
5. How do you handle conditional execution of steps in JCL? Explain the
COND= parameter.
o Answer: The COND= parameter on the EXEC statement allows a
step to execute based on the return codes of previous steps.
For example:
Code snippet
//STEP1 EXEC PGM=PROG1
//STEP2 EXEC PGM=PROG2,COND=((0,NE,STEP1))
STEP2 will execute only if STEP1's return code is not equal to 0. Other
operators like EQ, GT, LT, GE, LE, and keywords like EVEN and ONLY are
also used.
6. What is the difference between JOBLIB and STEPLIB? When would
you use each?
o Answer: JOBLIB (placed after the JOB card) specifies private
libraries to be searched for all programs in the job. STEPLIB
(placed after an EXEC card) specifies private libraries to be
searched only for the program in that specific step, overriding
JOBLIB. JOBLIB is used when most steps use the same private
libraries. STEPLIB is used when a specific step needs different
or specific versions of libraries.
7. Explain the use of cataloged procedures and in-stream procedures in
JCL. What are their advantages?
o Answer:
Cataloged Procedures: Stored in a system library (like
[Link]) and can be invoked by multiple jobs using
EXEC PROC=procedure_name.
In-stream Procedures: Defined within the JCL job itself,
starting with a PROC statement and ending with a PEND
statement. They are local to that job.
o Advantages: Reusability, standardization, reduced coding
errors, easier maintenance.
8. How do you override parameters within a cataloged procedure?
o Answer: Parameters in a cataloged procedure can be
overridden in the EXEC statement that calls the procedure by
specifying the parameter name followed by an equal sign and
the new value:
Code snippet
//STEP1 EXEC
PROC=MYPROC,INPUTFILE=[Link],OUTPUTFILE=[Link]
Assuming INPUTFILE and OUTPUTFILE are symbolic parameters in
MYPROC.
9. What are symbolic parameters in JCL, and how are they used?
o Answer: Symbolic parameters are variables defined with an
ampersand (&) that can be used in JCL statements. They are
assigned values at the JOB or EXEC level or within a procedure.
They provide flexibility and allow for customization of JCL
without modifying the base code. (See the detailed answer to
the tough question on symbolic parameters).
10. Describe a scenario where you would use the RESTART
parameter in the JOB statement.
o Answer: The RESTART parameter is used to restart a job from a
specific step after it has abended. This avoids re-running the
entire job. You would specify the step name or step number
where you want the job to resume execution.
11. How can you check the syntax of JCL without executing the
job?
o Answer: You can use the TYPRUN=SCAN parameter on the JOB
card. This will cause the system to check the JCL syntax for
errors without actually executing any of the steps.
12. Explain how you would allocate a new VSAM dataset using JCL.
o Answer: Allocating a VSAM dataset requires using the IDCAMS
(Integrated Data Cluster Access Method Services) utility within
a JCL job. You would use the DEFINE CLUSTER, DEFINE DATA,
and DEFINE INDEX commands within the SYSIN DD statement
to specify the characteristics of the VSAM dataset (e.g., key
length, record size, space allocation).
13. How do you copy data from one dataset to another using JCL?
o Answer: You can use utility programs like IEBCOPY (for
PDS/PDSE datasets) or IEBGENER (for sequential datasets)
within a JCL job. You would define the input and output
datasets using SYSUT1 and SYSUT2 DD statements
respectively, and provide control statements (if needed) via
SYSIN.
14. How do you sort a dataset using JCL?
o Answer: You would use the SORT utility within a JCL job. The
input dataset is defined by the SORTIN DD statement, the
output dataset by SORTOUT, and the sorting criteria are
specified in the SORT FIELDS= control statement within the
SYSIN DD statement.
15. How do you handle errors in JCL? What are return codes and
how are they used?
o Answer: Error handling in JCL primarily involves the COND=
parameter to control step execution based on return codes.
Return codes are numeric values (0-4095) issued by programs
at the end of their execution, indicating their success or
failure. JCL uses these return codes to make decisions about
subsequent steps. The IF/THEN/ELSE/ENDIF statements (in
more advanced JCL implementations or via utilities) also
provide conditional logic.
Conceptual JCL Questions
1. Explain the concept of symbolic parameters in JCL. How are they
defined, used, and overridden? Provide a practical example.
Answer: Symbolic parameters are variables within JCL that allow for greater
flexibility and reusability. They are defined with an ampersand (&) followed by a
name (e.g., &DATE, &PROGNAME).
Definition: Symbolic parameters can be defined in:
o The JOB statement: //MYJOB JOB (ACCT),NAME='&USERNAME'
o The EXEC statement: //STEP1 EXEC
PGM=&PROGNAME,PARM='&INPUTFILE'
o Within a cataloged or in-stream procedure.
Usage: Once defined, they are referenced by their name (e.g.,
DSN=[Link].&DATE). The system substitutes the actual value for the
symbolic parameter before executing the job step.
Overriding: Values assigned to symbolic parameters can be overridden at
the JOB or EXEC statement level when calling a procedure:
Code snippet
//MYJOB JOB ...
//STEP1 EXEC PROC=MYPROC,PROGNAME=MYPROG2,DATE='20250414'
In this example, &PROGNAME in MYPROC will be overridden with MYPROG2, and
&DATE (if defined in the PROC or earlier) will be overridden with 20250414.
Practical Example:
Code snippet
//*PROCEDURE MYPROC
//STEP1 EXEC PGM=&PGMNAME
//INFILE DD DSN=INPUT.&DATE,DISP=SHR
//OUTFILE DD DSN=OUTPUT.&DATE..REPORT,DISP=(NEW,CATLG,DELETE)
//*
//MYJOB JOB (ACCT),CLASS=A,MSGCLASS=X
//STEP01 EXEC PROC=MYPROC,PGMNAME=PROGA,DATE=TODAY
//STEP02 EXEC PROC=MYPROC,PGMNAME=PROGB,DATE=YESTERDY
In this example, the MYPROC is called twice. In STEP01, &PGMNAME becomes
PROGA and &DATE becomes TODAY. In STEP02, &PGMNAME becomes PROGB and
&DATE becomes YESTERDY.
2. Explain the purpose and usage of the INCLUDE statement in JCL. What
are its limitations?
Answer: The INCLUDE statement allows you to insert JCL statements from a
member of a partitioned dataset (PDS) or partitioned dataset extended (PDSE) into
your current JCL stream. This promotes modularity and reusability of common JCL
code.
Purpose:
o Reduces redundancy by storing frequently used JCL (like standard DD
statements for common datasets or standard EXEC statements with
common parameters) in a central location.
o Improves maintainability by allowing changes to common JCL to be
made in one place, affecting all jobs that include it.
o Enhances readability by breaking down large JCLs into smaller, more
manageable units.
Usage: The syntax is:
Code snippet
//DDname DD DSN=[Link],DISP=SHR
//STEPNAME EXEC PGM=...
//INCLUDED DD DSN=[Link],MEMBER=COMMONPARMS
//OUTPUT DD ...
The INCLUDE statement itself must be preceded by a valid DD statement defining
the library containing the member to be included. The included member contains
standard JCL statements (JOB, EXEC, and DD statements are typical).
Limitations:
o Cannot include JOB or PROC statements: Included members
cannot contain JOB or PROC statements.
o Nesting Limit: There's a limit to how deeply INCLUDE statements can
be nested (typically around 15 levels).
o DDname Requirement: The INCLUDE statement must be preceded
by a DD statement defining the library.
o Placement Restrictions: While generally flexible within a job step,
placement within complex conditional logic might lead to unexpected
results if not carefully managed.
o No Symbolic Parameter Resolution Before Inclusion: Symbolic
parameters within the including JCL are not resolved before the
included JCL is inserted. Resolution happens later in the JCL processing.
3. How can you conditionally execute JCL steps based on the return code
of previous steps? Explain the COND= parameter and provide different
examples.
Answer: The COND= parameter on the EXEC statement allows you to specify
conditions based on the return codes of previously executed steps. A step will
execute only if the specified condition evaluates to true.
The syntax of the COND= parameter is:
Code snippet
//STEPNAME EXEC PGM=...,COND=(value,operator,stepname)
Where:
value: A numeric return code value (0-4095).
operator: A relational operator:
o EQ or = (equal to)
o NE or ¬= (not equal to)
o GT or > (greater than)
o LT or < (less than)
o GE or >= (greater than or equal to)
o LE or <= (less than or equal to)
stepname: The name of a previously executed step. If omitted, the condition
applies to the return code of the immediately preceding step.
Multiple conditions can be specified within parentheses, separated by commas. All
conditions must be true for the step to be skipped.
Examples:
Execute STEP2 only if STEP1 completed successfully (return code 0):
Code snippet
//STEP1 EXEC PGM=PROG1
//STEP2 EXEC PGM=PROG2,COND=((0,NE,STEP1))
Execute STEP3 if STEP2 abended (return code greater than 0,
implicitly):
Code snippet
//STEP2 EXEC PGM=PROG2
//STEP3 EXEC PGM=PROG3,COND=EVEN
EVEN means execute if any preceding step (including the immediately preceding
one) ended.
Execute STEP4 only if STEP3 abended (return code greater than 0) or
had a return code of 8:
Code snippet
//STEP3 EXEC PGM=PROG3
//STEP4 EXEC PGM=PROG4,COND=((0,NE,STEP3),(8,NE,STEP3))
Execute STEP5 only if STEP4 had a return code greater than or equal
to 4:
Code snippet
//STEP4 EXEC PGM=PROG4
//STEP5 EXEC PGM=PROG5,COND=((4,LE))
Execute STEP6 always, regardless of previous step outcomes:
Code snippet
//STEP6 EXEC PGM=PROG6,COND=NEVER
NEVER means never skip the step based on return codes.
4. What is a Generation Data Group (GDG)? How do you create a GDG base
and reference specific generations in JCL? Explain the DISP parameter
usage with GDGs.
Answer: A Generation Data Group (GDG) is a collection of chronologically or
logically related datasets that are kept and managed as a group. Each dataset in
the GDG is called a generation.
Creating a GDG Base: The GDG base (the control information for the GDG) is
created using the IDCAMS utility:
Code snippet
//CREATEGDG JOB ...
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE GENERATIONDATAGROUP -
(NAME([Link]) -
LIMIT(5) - /* Maximum number of generations */
EMPTY - /* Delete oldest when limit is reached */
SCRATCH) /* Delete physical file when rolled off */
/*
Referencing Specific Generations:
Current Generation: [Link](0)
New Generation: [Link](+1) (used when creating a new
generation)
Previous Generations: [Link](-1), [Link](-2),
etc. (referring to the immediately preceding, second preceding, etc.)
Specific Generation Number: [Link](GnnnnVmm) (where
nnnn is the generation number and mm is the version number, though
version numbers are less commonly used)
DISP Parameter Usage with GDGs:
The DISP parameter is crucial when working with GDGs:
Creating a New Generation ([Link](+1)):
o DISP=(NEW,CATLG,DELETE): Creates the new generation. If the step
completes normally, the new generation is cataloged into the GDG
base. If the step abends, the uncataloged new generation is deleted.
o DISP=(NEW,PASS,DELETE): Creates the new generation and passes it
to subsequent steps. It's typically cataloged in a later step. If the step
abends, it's deleted.
Using an Existing Generation ([Link](0),
[Link](-n)):
o DISP=SHR: Allows multiple jobs to read the existing generation
concurrently.
o DISP=OLD: Gives exclusive access to the existing generation. Use with
caution as it prevents other jobs from accessing it.
o DISP=MOD: Allows appending new records to the end of an existing
sequential generation.
Handling Existing Generations After the Step: The third subparameter
of DISP (for existing generations) usually specifies what to do after the step
completes (e.g., KEEP, CATLG, UNCATLG, DELETE).
5. Explain the difference between JOBLIB and STEPLIB in JCL. When would
you use each? What is their search order for load modules?
Answer: JOBLIB and STEPLIB are DD statements used to specify private libraries
(non-system libraries) where the system should search for load modules
(executable programs) for the job.
JOBLIB: This DD statement, if present, must appear immediately after the
JOB statement. It defines private libraries that will be searched for all
executable programs within all steps of the job.
STEPLIB: This DD statement appears within a specific job step (after the
EXEC statement of that step). It defines private libraries that will only be
searched for the executable program of that particular step. STEPLIB
overrides any JOBLIB specified for that step.
When to Use Each:
JOBLIB: Use JOBLIB when all or most of the executable programs in the
different steps of a job reside in the same private libraries. This avoids
repeating the same library definitions in multiple STEPLIB statements.
STEPLIB: Use STEPLIB in the following scenarios:
o When a specific step requires a program from a private library that is
different from the libraries used by other steps in the job.
o When you want to use a specific version of a program for a particular
step, overriding a potentially different version in a JOBLIB.
o When the private libraries are only needed for a single step, keeping
the job-level library search path cleaner.
Search Order for Load Modules:
When the system needs to locate a load module for an EXEC PGM=program-name
statement, it searches the libraries in the following order:
1. STEPLIB (if present in the current step): The private libraries defined in
the STEPLIB DD statement are searched first, in the order they are listed.
2. JOBLIB (if present in the job): If the program is not found in STEPLIB (or if
STEPLIB is not specified), the private libraries defined in the JOBLIB DD
statement are searched, in the order they are listed.
3. System Libraries (LINKLIST/LPALIB): If the program is not found in either
STEPLIB or JOBLIB, the system searches the standard system libraries defined
in the Link Pack Area (LPA) and Link List. These libraries contain commonly
used system programs and utilities.
Basic COBOL
1. What does COBOL stand for?
o Answer: COBOL stands for Common Business-Oriented Language.
2. What are the four divisions of a COBOL program?
o Answer: The four divisions are:
Identification Division: Identifies the program.
Environment Division: Describes the hardware and software
environment.
Data Division: Describes the data used in the program.
Procedure Division: Contains the program's logic.
3. What is the purpose of the Identification Division?
o Answer: It provides basic information about the program, such as its
name, author, and installation. It's primarily for documentation. The
PROGRAM-ID paragraph is mandatory.
4. What is the purpose of the Environment Division?
o Answer: It describes the external environment in which the program
will run. It has two sections:
Configuration Section: Describes the overall system
configuration.
Input-Output Section: Deals with file definitions.
5. What is the purpose of the Data Division?
o Answer: It describes all the data items that the program will use. It
has several sections, including:
File Section: Describes the structure of external files.
Working-Storage Section: Defines internal variables and work
areas.
Local-Storage Section: Defines variables allocated each time
the program is called and deallocated upon exit.
Linkage Section: Describes data passed between programs.
6. What is the purpose of the Procedure Division?
o Answer: It contains the executable statements that define the logic of
the program. It's organized into sections and paragraphs.
7. What is a PIC clause and what is it used for?
o Answer: PIC (PICTURE) clause describes the format and characteristics
of a data item, such as its size, data type (numeric, alphabetic,
alphanumeric), and the position of the decimal point.
8. What is the difference between a level 77 and a level 01 item?
o Answer:
Level 01: Represents a major data structure or a record. It's the
most inclusive level.
Level 77: Represents an independent elementary item (a single
data item that is not part of a larger structure).
9. What is the purpose of the MOVE statement?
o Answer: The MOVE statement is used to transfer data from one data
item to another.
[Link] is the purpose of the DISPLAY statement?
o Answer: The DISPLAY statement is used to output data to the system
output device (usually the console or job log).
[Link] are the basic data types available in COBOL?
o Answer: The main data types are:
Numeric: Represents numerical values (PIC 9).
Alphabetic: Represents alphabetic characters (PIC A).
Alphanumeric: Represents a combination of alphabetic,
numeric, and special characters (PIC X).
[Link] is a literal in COBOL? What are the different types of literals?
o Answer: A literal is a constant value that appears directly in the
source code. The types are:
Numeric Literals: Consist of digits, optionally with a decimal
point and a sign.
Non-numeric Literals (String Literals): Enclosed in quotation
marks.
[Link] is the purpose of the STOP RUN statement?
o Answer: The STOP RUN statement terminates the execution of the
COBOL program and returns control to the operating system. It also
closes any open files associated with the program.
[Link] is a COBOL paragraph and a COBOL section?
o Answer:
Paragraph: A logical unit within the Procedure Division,
consisting of one or more sentences. It has a paragraph name
followed by a period.
Section: A larger logical division within a division (primarily in
the Environment and Procedure Divisions). It has a section name
followed by the keyword SECTION and a period. Paragraphs are
contained within sections in the Procedure Division.
[Link] is the significance of Area A and Area B in COBOL coding?
o Answer: COBOL source code has specific formatting rules:
Area A (Columns 8-11): Used for division headers, section
headers, paragraph names, and level indicators 01 and 77.
Area B (Columns 12-72): Used for all other COBOL
statements.
Conceptual COBOL Questions
1. Explain the different file organizations in COBOL and when you
would use each.
o Answer:
Sequential: Records are processed in the order they appear in
the file. Used for simple data processing, reports, and backups.
Indexed: Records are accessed using a key field, allowing for
both sequential and direct access. Used for applications
requiring fast retrieval based on a key (e.g., customer records).
Relative: Records are accessed by a relative record number.
Used for direct access based on a calculated record position.
2. Describe the different OPEN modes for files in COBOL.
o Answer:
INPUT: Opens a file for reading only.
OUTPUT: Opens a file for writing only. If the file exists, its
contents are usually overwritten.
I-O: Opens a file for both reading and writing (updating).
EXTEND: Opens a sequential file to append records at the end.
3. How do you handle file I/O errors in COBOL? Explain the AT END and
INVALID KEY clauses.
o Answer:
AT END: Used with READ statements for sequential files. It's
executed when the end of the file is reached.
INVALID KEY: Used with READ, REWRITE, and START
statements for indexed and relative files. It's executed when an
attempt is made to access a record with a non-existent key (for
READ or START) or a duplicate key (for WRITE where duplicates
are not allowed).
o The FILE STATUS clause in the FILE-CONTROL paragraph can also be
used to get a more detailed error code after each I/O operation.
4. What is the purpose of the PERFORM statement and explain its
various forms.
o Answer: The PERFORM statement is used to execute a section or
paragraph, and then return control to the statement following the
PERFORM. Forms include:
PERFORM paragraph-name: Executes the paragraph once.
PERFORM section-name: Executes all paragraphs within the
section once.
PERFORM paragraph-name THRU paragraph-name: Executes a
sequence of paragraphs.
PERFORM paragraph-name integer TIMES: Executes the
paragraph a specified number of times.
PERFORM paragraph-name UNTIL condition: Executes the
paragraph repeatedly until the condition is true (test before).
PERFORM paragraph-name VARYING identifier FROM initial BY
increment UNTIL condition: Executes the paragraph repeatedly
while varying the value of an identifier.
PERFORM paragraph-name WITH TEST BEFORE/AFTER UNTIL
condition: Explicitly specifies whether the condition is tested
before or after the first execution.
INLINE PERFORM: The statements to be performed are included
directly within the PERFORM statement, using END-PERFORM as
a terminator.
5. Explain the concept of subprograms in COBOL. How do you call a
subprogram and pass data to it?
o Answer: A subprogram is a separate COBOL program that can be
called by another (calling) program. This promotes modularity.
o Calling a subprogram: Use the CALL statement:
COBOL
CALL 'SUBPROG' USING data-item1 data-item2.
o Passing data: The USING clause in the CALL statement lists the data
items being passed. The corresponding subprogram must have a
LINKAGE SECTION in its Data Division and a PROCEDURE DIVISION
USING clause to receive the data.
6. What is the purpose of the COPY statement and the REPLACING
option?
o Answer: The COPY statement includes COBOL source code from a
copybook (a separate file or library member) into the current program.
The REPLACING option allows you to replace specific text within the
copied code with other text:
COBOL
COPY MY-RECORD-LAYOUT REPLACING ==OLD-FIELD== BY ==NEW-FIELD==.
7. Explain the use of tables in COBOL using the OCCURS clause. How do
you access elements in a table using subscripts and indexes? What
is the INDEXED BY clause?
o Answer: The OCCURS clause defines a table (an array) within the Data
Division, specifying the number of times a data item is repeated.
o Subscripts: Integer values used to reference elements in a table.
They must be within the bounds defined by the OCCURS clause. You
usually need to initialize subscripts before using them.
o Indexes: Special variables associated with a table using the INDEXED
BY clause. They represent displacement from the beginning of the
table and are typically manipulated using the SET, PERFORM VARYING,
and SEARCH statements. Indexing is generally more efficient than
subscripting for table processing.
o INDEXED BY: This clause in the OCCURS entry defines one or more
index names for the table, allowing you to use these index names for
accessing table elements.
8. What is the SEARCH statement and how is it used for table
processing? What is the difference between SEARCH and SEARCH
ALL?
o Answer: The SEARCH statement is used to find a specific element in a
table. It requires the INDEXED BY clause to be used in the OCCURS
entry. You need to SET the index to a starting value before the
SEARCH. The WHEN clause specifies the condition to be met.
o SEARCH (Sequential Search): Examines the table elements
sequentially until the condition in the WHEN clause is met.
o SEARCH ALL (Binary Search): Used for tables where the search key
is sorted. It uses a more efficient binary search algorithm to quickly
locate the element. The WITH KEY clause must be used to specify the
sorted key.
9. How do you sort data in COBOL using the SORT statement? Explain
the INPUT PROCEDURE and OUTPUT PROCEDURE clauses.
o Answer: The SORT statement sorts records from one or more input
files or an internal table and writes the sorted records to an output file
or an internal table.
o INPUT PROCEDURE: An optional section in the Procedure Division
that is executed before the sort operation begins. It allows you to
process input records (e.g., select, modify) before they are released to
the sort. Records are released to the sort using the RELEASE
statement.
o OUTPUT PROCEDURE: An optional section in the Procedure Division
that is executed after the sort operation is complete. It allows you to
process the sorted records (e.g., format, write to a file). Sorted records
are retrieved from the sort work file using the RETURN statement.
[Link] are EXEC SQL statements in COBOL and how are they used to
interact with databases like DB2? What are DBRMs and Plans?
o Answer: EXEC SQL statements are embedded SQL statements within
a COBOL program, allowing it to interact with a database (like DB2).
These statements are processed by a precompiler before the COBOL
compiler.
o DBRM (Database Request Module): The precompiler extracts the
EXEC SQL statements from the COBOL program and creates a DBRM,
which contains the SQL statements.
o Plan: A plan is created by the DB2 BIND process. It's an optimized
access path that DB2 will use to execute the SQL statements in the
DBRM. The BIND process takes the DBRM as input and determines the
most efficient way to access the database based on indexes, table
statistics, etc. The plan is stored in the DB2 catalog.
[Link] the concept of CICS and how COBOL programs interact with
CICS.
o Answer: CICS (Customer Information Control System) is a transaction
processing system for IBM mainframes, used for online transaction
processing (OLTP). COBOL is a common language for writing CICS
application programs.
o COBOL programs interact with CICS using special EXEC CICS
commands embedded in the COBOL code. These commands allow the
program to perform tasks such as:
Receiving input from terminals.
Sending output to terminals.
Reading and writing to CICS files (VSAM).
Accessing DB2 databases.
Managing transactions.
Handling errors.
[Link] do you debug COBOL programs in a mainframe environment?
What debugging tools or techniques have you used?
o Answer: Common debugging techniques and tools include:
DISPLAY statements: Inserting temporary DISPLAY statements
to trace program flow and variable values.
Abend-AID/InterTest: Powerful debugging tools that allow
setting breakpoints, stepping through code, examining
variables, and analyzing dumps.
z/OS Debugger: A more modern interactive debugger for z/OS.
Execution traces: Analyzing the sequence of executed
paragraphs and sections.
Analyzing system dumps: Examining memory snapshots after
a program abend to understand the state of the program and
data.
[Link] techniques for optimizing the performance of COBOL
programs.
o Answer: Techniques include:
Efficient file access: Minimizing I/O operations, using
appropriate file organizations, optimizing block sizes.
Optimizing loops: Reducing the number of iterations, moving
invariant code outside loops.
Efficient table handling: Using indexes for searching,
minimizing table searches.
Using appropriate data types: Choosing efficient data
representations (e.g., binary or packed decimal for numeric
calculations).
Minimizing string manipulations.
Careful use of PERFORM THRU (can sometimes be less
efficient than structured PERFORM with END-PERFORM).
SQL optimization (for programs using DB2).
[Link] the use of the REDEFINE and RENAMES clauses in the Data
Division.
o Answer:
REDEFINE: Allows you to give an alternative description
(different data type or structure) to the same area of storage.
The redefined field shares the same memory locations as the
original field.
RENAMES: Allows you to group non-contiguous elementary
items within a record under a single name. It provides a way to
treat a subset of fields as a single logical unit. Level 66 is used
for RENAMES.
[Link] do you handle date and time manipulation in COBOL? What are
some intrinsic functions available?
o Answer: COBOL has some built-in features and intrinsic functions for
date and time:
ACCEPT statement: Can be used to get the current date and
time from the system (ACCEPT CURRENT-DATE, ACCEPT TIME).
Intrinsic Functions: COBOL 85 introduced several intrinsic
functions for date and time manipulation, such as:
DATE-OF-INTEGER: Converts a Julian date to Gregorian.
DAY-OF-INTEGER: Converts a Julian date to a year and day
of year.
INTEGER-OF-DATE: Converts a Gregorian date to Julian.
INTEGER-OF-DAY: Converts a year and day of year to
Julian.
FORMATTED-DATE: Formats a date according to a
specified pattern.
FORMATTED-TIME: Formats a time according to a
specified pattern.
You often need to perform calculations and formatting manually
for more complex date/time operations, especially in older
COBOL versions.
Conceptual Cobol questions
For Experienced Professionals:
1. Compare and contrast Sequential and Indexed file organizations.
o Answer: Sequential access is ordered by physical position, suitable for
batch processing. Indexed access uses a key for direct and sequential
access, ideal for online transaction processing.
2. Explain the implications of opening a file in OUTPUT mode if the file
already exists.
o Answer: Typically, the existing content of the file is overwritten.
3. How do you detect the end of a sequential file during reading?
o Answer: Using the AT END clause in the READ statement.
4. Describe a scenario where you would use PERFORM VARYING.
o Answer: To iterate through elements of a table or perform a set of
operations a specific number of times while changing a control
variable.
5. What is the LINKAGE SECTION used for?
o Answer: To describe data items that are passed to or received from a
calling program or subprogram.
6. How can you make a section of code reusable within the same
program?
o Answer: By using PERFORM on a paragraph or section name.
7. What is the benefit of using copybooks?
o Answer: Promotes code reusability, standardization of data structures,
and easier maintenance.
8. Explain the difference between a subscript and an index when
accessing table elements.
o Answer: A subscript is a direct occurrence number, while an index
represents displacement and is typically used with INDEXED BY for
more efficient processing with SEARCH and SET.
9. When would you use SEARCH ALL instead of SEARCH?
o Answer: When the table is sorted based on the search key, as
SEARCH ALL uses a more efficient binary search.
[Link] is the purpose of the SORT work files?
o Answer: They are temporary storage areas used by the SORT utility to
hold the records being sorted.
[Link] is the role of the COBOL precompiler when using embedded
SQL?
o Answer: It translates the EXEC SQL statements into host language
code that can be understood by the COBOL compiler and creates a
DBRM.
[Link] does a COBOL program send data to a CICS terminal?
o Answer: Using EXEC CICS SEND MAP or EXEC CICS SEND TEXT.
[Link] a common COBOL debugging tool in a mainframe environment.
o Answer: Abend-AID or z/OS Debugger.
[Link] is a potential performance issue with excessive file I/O in
COBOL?
o Answer: It can significantly slow down program execution due to the
relatively slow speed of disk operations compared to memory access.
[Link] is the purpose of the INITIALIZE statement?
o Answer: To set data items to their default values (e.g., numeric fields
to zero, alphanumeric fields to spaces).
Scenario-Based Questions (for Experienced Professionals):
1. You need to read a file where records can have different layouts.
How would you define this in the Data Division?
o Answer: Using REDEFINE to provide different record descriptions for
the same file area based on a record type indicator.
2. A COBOL program is abending with an S0C7 error. What is the most
likely cause?
o Answer: An attempt to perform an arithmetic operation on non-
numeric data.
3. How would you optimize a COBOL program that frequently searches
a large unsorted table?
o Answer: If possible, sort the table and use SEARCH ALL. If sorting is
not feasible, consider using an index or restructuring the data access if
the search criteria are predictable.
4. You need to call a subprogram and pass a large data structure. How
would you define this in both the calling and called programs?
o Answer: Define the data structure as a level 01 item in the Working-
Storage of the calling program and the Linkage Section of the
subprogram, using corresponding PIC clauses. The USING clause in the
CALL and PROCEDURE DIVISION statements would link them.
5. How would you handle a situation where a CICS COBOL program
needs to access data from a DB2 database?
o Answer: By embedding EXEC SQL statements within the COBOL
program to interact with DB2. A plan would need to be created and
associated with the program.
VSAM Baiscs:
1. What does VSAM stand for?
o Answer: Virtual Storage Access Method.
2. What is VSAM?
o Answer: VSAM is a file access method used in IBM mainframe
operating systems (z/OS, MVS) for organizing and accessing data
efficiently. It manages data as files (datasets) with enhanced
performance and flexibility compared to older methods.
3. What are the different types of VSAM datasets?
o Answer: The main types are:
KSDS (Key-Sequenced Data Set): Records are stored and
accessed based on a key field.
ESDS (Entry-Sequenced Data Set): Records are stored and
accessed in the order they are entered.
RRDS (Relative Record Data Set): Records are stored in
fixed-length slots and accessed by their relative record number.
LDS (Linear Data Set): An unstructured byte stream, primarily
used by system components and databases.
4. What is a Control Interval (CI)?
o Answer: The Control Interval is the basic unit of data transfer between
virtual storage and auxiliary storage (DASD) in VSAM. It's analogous to
a physical block.
5. What is a Control Area (CA)?
o Answer: A Control Area is a group of contiguous Control Intervals on
DASD. It's a unit for space allocation and management.
6. What is a VSAM Cluster?
o Answer: For KSDS, the cluster is the combination of the data
component and the index component. For ESDS and RRDS, it's
primarily the data component. The cluster is the entity that programs
access.
7. What is the purpose of the VSAM Catalog?
o Answer: The VSAM Catalog contains metadata about VSAM datasets,
including their names, locations, and attributes. It's used to locate and
access VSAM datasets.
8. What is IDCAMS?
o Answer: IDCAMS (Integrated Data Cluster Access Method Services) is
a utility program used to define, create, delete, modify, list, and
manage VSAM and non-VSAM datasets.
9. What is the DEFINE CLUSTER command in IDCAMS used for?
o Answer: It's used to define a new VSAM dataset (cluster) and specify
its characteristics (type, record length, key length, space allocation,
etc.).
[Link] is the REPRO command in IDCAMS used for?
o Answer: It's used to copy data between VSAM datasets, sequential
datasets, and can also be used to load initial data into a VSAM dataset.
For Experienced Professionals:
1. Explain the key differences between KSDS, ESDS, and RRDS, and
when you would choose each.
o Answer:
KSDS: Accessed by key, allows efficient random and sequential
access based on the key. Suitable for applications needing fast
retrieval by a specific field (e.g., customer records).
ESDS: Accessed sequentially by order of entry or by Relative
Byte Address (RBA). Simpler structure, good for sequential
processing and logging.
RRDS: Accessed by Relative Record Number (RRN). Fixed-
length slots, allows direct access by slot number. Useful for
applications where records can be easily mapped to a slot
number (e.g., fixed-length arrays on disk).
2. What is an Alternate Index in VSAM? Why and how is it created and
used?
o Answer: An Alternate Index (AIX) provides an alternate way to access
a VSAM dataset (usually a KSDS or ESDS) using a key other than the
primary key. It's created using IDCAMS (DEFINE AIX, BLDINDEX) and
allows for efficient retrieval based on the alternate key. A PATH is
defined to link the AIX to the base cluster. COBOL programs use the
FILE-CONTROL entry to specify the alternate index.
3. Explain CI and CA splits in KSDS. What causes them and how can you
minimize them?
o Answer:
CI Split: Occurs in a KSDS when a new record needs to be
inserted into a full Control Interval. VSAM splits the CI, moving
some records to a new CI, which can impact performance.
CA Split: Occurs when all CIs in a Control Area are full and a CI
split is needed. VSAM splits the CA, moving some CIs to a new
CA, which has a more significant performance impact.
o Causes: Frequent insertions of records that fall within the key range of
full CIs or CAs.
o Minimizing: Allocate sufficient FREESPACE (both CI and CA free space
percentages) during the DEFINE CLUSTER step to accommodate future
insertions. Periodic reorganization of the VSAM dataset using IDCAMS
REORGANIZE can also help.
4. What are SHAREOPTIONS in VSAM? Explain the different values and
their implications.
o Answer: SHAREOPTIONS (specified in the DEFINE CLUSTER) control
how multiple users or jobs can access a VSAM dataset concurrently. It
has two parameters: (cross-region, cross-system).
(1, x): Exclusive control within the same system. No other job
can access the dataset.
(2, x): Multiple readers allowed, but only one writer.
(3, x): Multiple readers and writers allowed, but VSAM doesn't
guarantee data integrity. Application logic must handle
concurrency.
(4, x): Multiple readers and writers allowed, with VSAM
providing record-level locking for integrity.
The cross-system parameter (second value) controls sharing
across different systems in a Sysplex, with similar implications
for data integrity. Choosing the right SHAREOPTIONS is crucial
for data consistency and application concurrency.
5. How do you handle errors when accessing a VSAM dataset in COBOL?
Explain the FILE STATUS clause.
o Answer: The FILE STATUS clause in the FILE-CONTROL paragraph of
the Environment Division is used to monitor the outcome of each I/O
operation on a VSAM file. It defines a two-character field that will
contain a status code after each READ, WRITE, REWRITE, DELETE, or
START statement. The values of the file status code indicate the
success or failure of the operation and provide specific error
information (e.g., record not found, duplicate key). The COBOL
program should check the FILE STATUS after each I/O operation and
take appropriate action.
6. What is the purpose of the VERIFY command in IDCAMS? When
would you use it?
o Answer: The VERIFY command checks the structural integrity of a
KSDS index and the consistency between the index and the data
component. You would typically use it after a system failure or
abnormal termination of a job that was updating a KSDS, as these
events can sometimes lead to inconsistencies in the index.
7. Explain the concept of Record Level Sharing (RLS) in VSAM.
o Answer: Record Level Sharing (RLS) is a feature in a Parallel Sysplex
environment that allows multiple systems to concurrently read and
write to the same VSAM dataset with record-level locking managed by
GRS (Global Resource Serialization). This provides high concurrency
and data integrity for shared VSAM datasets in a Sysplex.
SHAREOPTIONS(4,4) is typically used for RLS.
8. How do you choose the optimal Control Interval (CI) size and
FREESPACE values for a KSDS?
o Answer: The optimal CI size depends on the application's I/O patterns.
Larger CIs can improve sequential access but might waste space if
records are small. Common sizes are 4K or 8K. FREESPACE should be
determined based on the expected frequency of record insertions.
Higher FREESPACE reduces CI/CA splits but increases the overall
dataset size. It's often a trade-off and might require monitoring and
tuning.
9. What are the considerations when converting a sequential file to a
VSAM KSDS?
o Answer:
Identifying a Primary Key: A KSDS requires a unique primary
key. You need to determine which field(s) in the sequential file
will serve as the key.
Sorting: The input sequential file must be sorted by the chosen
primary key before loading into the KSDS.
IDCAMS Definition: Define the KSDS cluster with the INDEXED
attribute and specify the key length and offset.
Loading Data: Use IDCAMS REPRO to load the sorted
sequential file into the newly defined KSDS.
[Link] do you back up and restore VSAM datasets? What IDCAMS
commands are used?
o Answer:
Backup:
REPRO: Can be used to copy a VSAM dataset to a
sequential file or another VSAM dataset.
EXPORT: Can be used to create a portable backup copy of
a VSAM dataset, including its definition.
Restore:
REPRO: Can be used to load data from a sequential file or
another VSAM dataset into an existing VSAM dataset.
IMPORT: Used to restore a VSAM dataset from a file
created by the EXPORT command.
CA7 Basics
1. What is CA7 Scheduler?
o Answer: CA7 is a workload automation and job scheduling tool used
on IBM mainframes to automate and manage the execution of batch
jobs. It controls when jobs run, based on time, dependencies, and other
defined criteria.
2. What are the three main queues in CA7?
o Answer: Request Queue (REQ), Ready Queue (RDY), and Active Queue
(ACT).
3. Explain the purpose of the Request Queue (REQ).
o Answer: Jobs enter the REQ queue when they are scheduled to run,
triggered by another job, or manually demanded. They wait here until
their requirements are met.
4. Explain the purpose of the Ready Queue (RDY).
o Answer: Jobs move to the RDY queue when all their prerequisites and
requirements are satisfied. They are waiting for the necessary system
resources (initiators) to become available to start execution.
5. Explain the purpose of the Active Queue (ACT).
o Answer: Jobs in the ACT queue are currently running or executing on
the mainframe system.
6. How can a job enter the Request Queue?
o Answer: Jobs can enter the Request Queue through scheduling
(SSCN), triggering (AUTO), or manual demand (DEMD).
7. What is a SCHID in CA7?
o Answer: SCHID (Schedule ID) is a number (1-255) that identifies a
specific schedule or set of run criteria for a job. A job can have multiple
SCHIDs for different run frequencies or conditions.
8. What is meant by "triggering" a job in CA7?
o Answer: Triggering (AUTO) means that the successful completion of a
"predecessor" job automatically causes another "successor" job to be
submitted to the Request Queue.
9. What is the purpose of the LJOB command?
o Answer: The LJOB command is used to list information about jobs in
CA7, such as their current status, schedule details, requirements, and
trigger information.
[Link] is the purpose of the LQ command?
o Answer: The LQ command is used to display the contents of the CA7
queues (Request, Ready, Active), showing the jobs currently waiting or
running.
VSAM Conceptual:
1. Explain the LEAD TIME concept in CA7. How can "look-back issues"
occur?
o Answer: Lead time defines a period before a job's scheduled run time
during which CA7 looks back at the completion status of its
predecessors to satisfy requirements. Look-back issues occur when a
predecessor completes successfully after the lead time window has
closed, causing the successor job to potentially wait unnecessarily or
not run as expected.
2. How do you handle job dependencies and requirements in CA7?
What are USR requirements?
o Answer: Job dependencies are defined through predecessor/successor
relationships and triggering. Requirements specify conditions that
must be met before a job can run (e.g., predecessor completion, file
availability). USR (User) requirements are manual requirements that
must be posted as satisfied by an operator using the POST command.
3. Describe the process of forecasting in CA7. What commands are
used?
o Answer: Forecasting predicts when jobs are likely to run based on
their schedules, dependencies, and current queue status. The FJOB
command is used to forecast jobs based on a time range, while FQJOB
forecasts based on the current queue and a time span.
4. How do you manage and resolve jobs stuck in the Active Late queue?
o Answer: Jobs in the Active Late queue have exceeded their expected
elapsed time. Troubleshooting involves checking job logs for loops or
hangs, verifying resource availability, and potentially intervening to
cancel or force complete the job if necessary, after investigation.
5. Explain the difference between a cataloged procedure and an in-
stream procedure in the context of CA7 job submissions.
o Answer: CA7 retrieves JCL from libraries. Whether the JCL points to a
cataloged procedure (in [Link] or similar) or contains an in-
stream procedure (defined within the JCL itself, starting with PROC and
ending with PEND) is determined by the JCL stored and managed by
CA7. CA7 itself doesn't differentiate in how it schedules the job, but the
JCL structure is important for execution.
6. How do you implement and manage calendars in CA7 for scheduling
exceptions (e.g., holidays)?
o Answer: Calendars are defined in CA7 to specify non-workdays or
special processing days. Jobs can be associated with calendars, and
their schedules can be defined to skip or adjust execution on specific
calendar dates. The LSCHD command with the LIST=CALS option is
used to view calendar assignments. The SCHDMOD screen is used to
modify schedule dates based on calendar exceptions.
7. Describe a scenario where you would use the NXTCYC=OFF
parameter.
o Answer: NXTCYC=OFF (Next Cycle Off) is used on scheduled jobs to
prevent them from automatically running on their next scheduled
cycle. This is useful for temporarily holding a job without deleting its
schedule, for example, during maintenance or troubleshooting.
8. How do you restart a job in CA7 after a failure? What considerations
are important?
o Answer: Jobs can be restarted using the RESTART command (often
through panels). Important considerations include identifying the
correct restart step, ensuring necessary data sets are in the correct
state, and understanding if the application supports restarting from a
specific point. JCL might need modification (e.g., including a RESTART
card).
9. Explain the purpose and usage of the #HLD, #NOX, and #NTR JCL
override commands in a CA7-controlled job.
o Answer: These are special JCL comments that CA7 interprets:
#HLD: Places the job in a held status in the Request Queue,
preventing it from automatically proceeding.
#NOX: Makes a scheduled or triggered job non-executable for
the current cycle. CA7 assumes a good end and triggers
successors but the job itself doesn't run.
#NTR: Prevents a job from triggering its successors, even if it
completes successfully.
[Link] do you troubleshoot a situation where a job is not triggering its
successor jobs?
o Answer: Troubleshooting involves verifying the trigger definition in
CA7 for the predecessor job (using LJOB,LIST=TRIG), checking the
completion status of the predecessor, ensuring the successor job's
requirements are met (using LJOB,LIST=RQMT for the successor), and
confirming that the successor job is not on hold or suppressed.
Scenario-Based Questions:
1. A critical production job that runs every morning has failed. Describe
the steps you would take to analyze the failure and get it restarted
as quickly as possible.
o Answer: (Focus on a systematic approach: acknowledge criticality,
check CA7 queues and job logs for abend codes and messages, identify
the failing step, investigate JCL and program logic if needed,
coordinate with application owners if it's a program issue, determine
the appropriate restart point, and execute the restart, followed by
monitoring).
2. You need to implement a new job that runs only on the last business
day of each month. How would you schedule this in CA7?
o Answer: (Involve creating or using a calendar that defines business
days and then scheduling the job based on that calendar, potentially
using a specific SCHID that checks for the last business day).
3. A job is taking significantly longer to run than its historical average.
How would you investigate this performance degradation using CA7
and other mainframe tools?
o Answer: (Describe using CA7 commands like LJOB to see current
status and elapsed time, comparing it to historical data from LPRRN,
and then using performance monitoring tools like SDSF or RMF to
analyze CPU usage, I/O activity, and wait times for the job's steps).