Mainframe Interview Questions: COBOL, DB2, and JCL

This section covers frequently asked mainframe interview questions, focusing on COBOL programming, DB2 database interactions, and JCL (Job Control Language).

Understanding the `NOTCAT 2-GS` Error

The NOTCAT 2-GS message in an IBM mainframe environment indicates a duplicate catalog entry for a dataset. This means a dataset with the specified name already exists in the system catalog. This typically occurs when attempting to catalog a dataset that already exists, causing a cataloging error.

JCL Procedures

JCL procedures are reusable blocks of JCL code. They encapsulate common job steps, promoting modularity and reducing redundancy. They often define the fixed part of the JCL, with parameters supplied when the procedure is invoked.

Procedure Invocation

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

Submitting a Job

Submitting a job means sending the JCL (and associated program code) to the mainframe's job scheduler for execution.

Submitting JCL from CICS

CICS (Customer Information Control System) provides commands to interact with the JES (Job Entry Subsystem) for job submission.

Holding a Job

You can specify TYPRUN=HOLD on the job card to prevent a job from immediately starting. The job will remain in a "hold" state until released by a system operator.

Storing and Retrieving Files in an Oracle Database

In an Oracle database, you typically use the CLOB (Character Large Object) data type to store large text files and the BLOB (Binary Large Object) datatype to store binary files. JDBC provides methods for this.

Storing a File (Example)

PreparedStatement ps = con.prepareStatement("INSERT INTO filetable VALUES (?, ?)");
ps.setInt(1, 101);
FileReader fr = new FileReader(file);
ps.setCharacterStream(2, fr, (int) file.length());
ps.executeUpdate();
Retrieving a File (Example)

ResultSet rs = stmt.executeQuery("SELECT * FROM filetable WHERE id=101");
rs.next();
Clob clob = rs.getClob("NAME");
Reader reader = clob.getCharacterStream();

Stored Procedures vs. Functions in Databases

Feature Stored Procedure Function
Purpose Perform complex database operations Perform calculations and return a value
Return Type No return value Returns a value
Parameters Input and output parameters Input parameters only
Exception Handling Can include error handling Typically doesn't include error handling

Maintaining Database Integrity with JDBC

Maintain database integrity using transactions (ACID properties: Atomicity, Consistency, Isolation, Durability). JDBC's Connection object provides methods for transaction management (setAutoCommit(), commit(), rollback()).

JDBC RowSet

A RowSet is a disconnected ResultSet. It's more flexible and can be used independently of a database connection. Several implementations of RowSet exist.

COBOL Coding Sheets

COBOL coding sheets provided a structured format for writing COBOL programs on punch cards (an older technology).

COPYBOOKs in COBOL

COPYBOOKs in COBOL are reusable code segments defining data structures. They're included in programs using the COPY statement to avoid repetitive coding.

COBOL Database Components

Interacting with DB2 from COBOL typically involves:

  • Embedded SQL statements.
  • DB2 application programming interfaces.
  • Host variables for data transfer.
  • SQLCA (SQL Communication Area) for status information.
  • Cursors for navigating results.

Rules for DB2 Programming in COBOL

[List the rules for writing embedded SQL statements in COBOL programs. This should include rules about delimiters, placement of SQL statements within the code, and declaring host variables.]

Host Variables

Host variables are variables defined in your COBOL program used to pass data to and from the DB2 database. They're prefixed with a colon (:) within embedded SQL statements.

Moving Alphanumeric to Numeric Fields

You can move alphanumeric data to a numeric field in COBOL, but this might cause errors during numeric operations if the data isn't properly formatted.

DB2 Databases

DB2 is IBM's relational database management system. A DB2 database consists of various components (tables, schemas, etc.) working together to manage data effectively.

Defining Files for COBOL Programs in JCL

The SORTWKnn DD statements define temporary work datasets for the sort utility used in JCL when processing COBOL programs.

The EVALUATE Statement in COBOL

The EVALUATE statement allows for multiple conditional branching in COBOL, similar to a switch or case statement in other languages.

Syntax

EVALUATE {expression}
    WHEN value1
        statements
    WHEN value2
        statements
    WHEN OTHER
        statements
END-EVALUATE

Types of EVALUATE Statements

The COBOL EVALUATE statement has several forms:

  • Simple EVALUATE
  • EVALUATE TRUE
  • EVALUATE with THRU (range)
  • EVALUATE with multiple WHEN conditions
  • EVALUATE with multiple conditions (using logical operators)

JCL (Job Control Language) Statements

JCL is a scripting language used on IBM mainframes for running batch jobs. It controls job execution, manages resources, and handles input/output operations.

Three main types of JCL statements:

  1. JOB statement: Identifies the job.
  2. EXEC statement(s): Specify the programs to be run (one EXEC per step).
  3. DD (Data Definition) statements: Define input and output datasets (files).

Accessing Uncatalogued Datasets in JCL

Access uncatalogued datasets by specifying the UNIT and VOLSER parameters in the dataset's DD statement. This tells the JCL which physical volume the dataset resides on.

The JOB Statement

The JOB statement is the first statement in a JCL job. It identifies the job to the operating system's job scheduler. It provides information about the job's name, accounting information, and other parameters.

Syntax

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

Mainframe Testing

Mainframe testing verifies the functionality of mainframe applications. It involves testing various aspects of the system, similar to web application testing, but with a focus on mainframe-specific technologies and tools.

Types of Mainframe Manual Testing

  • Batch Job Testing: Testing batch jobs.
  • Online Testing (CICS): Testing CICS screens (similar to testing web pages).