JCL (Job Control Language) Interview Questions and Answers

This section covers frequently asked JCL interview questions, focusing on its syntax, functionality, and use in mainframe environments.

What is JCL?

JCL (Job Control Language) is a scripting language used on IBM mainframe systems to submit batch jobs. It provides instructions to the operating system on how to execute a program, manage input/output files, and handle other aspects of the job's execution. It's essentially a set of commands that control the job's workflow.

JCL and COBOL Code

While JCL itself isn't a programming language like COBOL, it interacts with COBOL programs during execution. JCL statements guide the operating system in providing resources and controlling the flow of data.

  • Identification Division: Metadata about the JCL job.
  • Environment Division: Specifies files and resources needed by the COBOL program.
  • Data Division: Describes how the data in those files will be used by the COBOL program (READ, PRINT, etc.).
  • Procedure Division: Contains control statements that dictate actions based on file operations.

Condition Checking in JCL

Yes, JCL supports conditional processing using the COND parameter in the JOB or EXEC statements. This allows you to control job flow based on return codes or other conditions.

Automatic Restart in JCL

JCL allows for automatic restart capabilities using keywords like RD (restart). Checkpoints within the program are crucial for successful restarts, defining points from which execution can be resumed.

The JOB Statement

The JOB statement identifies the job to the operating system's job scheduler. It includes information like the job name, accounting information, and notification options.

Syntax

//jobname JOB (account-info), (other parameters)

The EXEC Statement

The EXEC statement specifies the program or procedure to be executed in a job step. It provides instructions on how to run the program.

Syntax

//stepname EXEC PGM=program-name, (other parameters)

ADDRSPC Parameter

The ADDRSPC parameter (in the EXEC statement) specifies the addressing space (real or virtual storage) for a job step. ADDRSPC=REAL prevents paging, impacting system performance.

Specifying a Job to the OS

JCL specifies a job to the operating system through a series of statements, including the JOB statement, EXEC statement(s), DD statements defining the files, and any necessary control statements.

The DD (Data Definition) Statement

The DD statement describes input and output datasets (mainframe files). It specifies file organization, record length, and other parameters.

Syntax

//ddname DD DSN=dataset-name,DISP=disposition, other parameters

Checking JCL Syntax Without Execution

Use the TYPERUN=SCAN option on the JOB card or the JSCAN utility to check JCL syntax without actually running the job.

JCL Statements Not Allowed in Procedures

  • JOB statement
  • Delimiter (/*)
  • Null statements
  • JOBLIB or JOBCAT statements
  • DD * or DATA statements
  • JES2 or JES3 control statements

The INCLUDE Statement

The INCLUDE statement is an alternative to STEPLIB. It allows you to include other JCL datasets, making it easier to manage libraries and datasets.

JOBLIB vs. STEPLIB

Statement JOBLIB STEPLIB
Scope Entire job Specific job step
Placement After JOB, before EXEC After EXEC, before step's DD statements
Procedures Cannot be in procedures Can be in procedures

The // Symbol

The // symbol is required at the beginning of every JCL statement. It signifies a JCL statement to the JCL processor.

JCL Hierarchy Levels

JCL statements have hierarchical levels, describing actions based on different keywords (NAME, FIELDS, OPERATIONS, OPERANDS, PARAMETERS, POSITIONAL, KEYWORD, COMMENTS).

Addressing Mode (AMODE) vs. Run Mode (RMODE)

Parameter AMODE RMODE
Purpose Specifies addressing space (24-bit or 31-bit) Specifies where the program is loaded (real or virtual storage)
Values 24, 31, ANY 24, 31, ANY

Running COBOL-DB2 Programs

The IKJEFT01 utility is used to run COBOL programs that interact with DB2.

Specifying Private Libraries

The JCLLIB statement defines private libraries to be searched for programs in a job step.

Syntax

//mylib JCLLIB ORDER=(lib1,lib2)

JCL Utility Programs

JCL provides various pre-written utility programs for tasks like copying, sorting, and managing datasets. Some common ones are IEBCOPY, DFSORT, and IDCAMS.

DFSORT Utility

DFSORT is a powerful utility for sorting, merging, and manipulating datasets on a mainframe.

DISP=(NEW,PASS,DELETE)

This DISP parameter creates a temporary dataset, passes it to the next step, and then deletes it after the job is complete.

Converting FB to VB Files

The FTOV option in the DFSORT utility converts a FB (Fixed Block) file to a VB (Variable Block) file.

Running a COBOL Program with JCL

[Include a JCL example to run a COBOL program. This example should show how to specify the program name, libraries, input files, and output files.]

Generation Data Groups (GDGs)

GDGs are groups of related datasets managed by generation numbers. New generations are added, old ones are deleted, and intermediate generations might be retained.

Creating Temporary Datasets

Create temporary datasets using DSN=&&tempname in the DD statement, or by omitting the DSNAME parameter. Temporary datasets are automatically deleted after the job completes.

Understanding NOTCAT 2-GS

The NOTCAT 2-GS message in MVS indicates a duplicate catalog entry for a dataset. This usually happens when you try to catalog a dataset that already exists in the system catalog. To resolve this, either delete the existing dataset or correct the catalog entry for the new dataset.

JCL Procedures

JCL procedures are reusable sets of JCL statements. They group together common JCL instructions, allowing you to avoid repetitive coding and improve maintainability. Procedures are particularly useful for executing the same job steps multiple times, possibly with different parameters for each run (e.g., using multiple input files).

Procedure Syntax

//stepname EXEC PROC=procname,param1=value1,param2=value2

Submitting a Job for Execution

Submitting a job involves sending your JCL to the mainframe's job scheduler for processing. This initiates the execution of your job steps.

Submitting JCL from CICS

CICS (Customer Information Control System) provides an interface to JES (Job Entry Subsystem), the mainframe's job submission system. This interface lets you submit JCL from within a CICS program using SPOOL interface commands (SPOOLOPEN, SPOOLWRITE, SPOOLREAD, SPOOLCLOSE).

Holding a Job

To hold a job from execution, specify TYPRUN=HOLD on the JOB statement. The job will remain in the hold state until it's manually released.

Example

//myjob JOB (acctinfo),CLASS=A,TYPRUN=HOLD