Mainframe interview questions and answers: COBOL, JCL, DB2 and CICS

Mainframe interview questions test whether you can build and support the batch and online systems that run on IBM Z: COBOL programs with packed decimal data and file handling, JCL that runs them in the right order with the right datasets, DB2 for relational data, CICS for transactions, and VSAM for keyed files. Most interviews mix definitions with production support scenarios, such as a nightly job that abends with S0C7 or a DB2 step that ends with SQLCODE -911, and they reward people who know what to check first.

By Published 8 min read

Who gets asked mainframe questions

Banks, insurers, airlines, retailers and government agencies still run core batch and transaction systems on z/OS, and the services firms that support them hire for it steadily. Roles include COBOL developer, mainframe production support, DB2 or CICS specialist, batch scheduler and modernization engineer. Freshers usually face a theory round on COBOL and JCL after company training. Experienced candidates get scenario questions from production support: abends, restarts, performance and data fixes. Expect some database talk too, and SQL interview questions is a good refresher for the DB2 side.

COBOL fundamentals

Language questions for freshers and developer screens
QuestionWhat it testsWhat a strong answer shows
Name the four divisions of a COBOL program.StructureIDENTIFICATION, ENVIRONMENT, DATA and PROCEDURE. DATA holds the FILE, WORKING-STORAGE and LINKAGE sections; LINKAGE describes data passed in by a caller.
DISPLAY, COMP and COMP-3: what is the difference?Data storageDISPLAY stores one character per digit. COMP is binary. COMP-3 is packed decimal, two digits per byte with the sign in the last half-byte, which is compact and exact for money.
How many bytes does PIC S9(7) COMP-3 take?Arithmetic of storageFour. Packed decimal needs (digits + 1) / 2 bytes, rounded up: seven digits plus a sign is eight half-bytes.
What is the V in PIC S9(5)V99?Implied decimalAn assumed decimal point. No character is stored for it; the program and the copybook agree on where it is.
What are level 66, 77 and 88?Level numbers66 renames a range of fields, 77 is a standalone item, and 88 is a condition name, a readable true or false test on a field's value.
What does REDEFINES do, and what is the risk?Memory layoutIt gives the same storage a second description, often for different record types. Reading it through the wrong layout gives garbage or a data exception.
SEARCH versus SEARCH ALL?TablesSEARCH is a sequential scan from the current index. SEARCH ALL is a binary search and needs the table sorted on a declared key.
Subscript versus index?TablesA subscript is an ordinary number field that the program converts to an offset. An index holds the offset itself, set with SET, and is usually faster.
Static versus dynamic CALL?LinkingA static call links the subprogram into the load module at link-edit time. A dynamic call loads it at run time, so it can be changed without relinking the caller, at some cost per call.
What do file status codes 00, 10, 23 and 35 mean?File handling00 success, 10 end of file, 23 record not found on a keyed read, and 35 file not found at OPEN. Check status after every I/O rather than trusting AT END alone.
What are COPY and copybooks for?ReuseShared record layouts and code pulled in at compile time, so every program reading a file agrees on its structure.
What does INITIALIZE do?Data handlingSets alphanumeric fields to spaces and numeric fields to zero within a group, which avoids leftover data from the previous record.
Language questions for freshers and developer screens. Scroll sideways on a small screen.
       01  WS-TRANS-REC.
           05  TR-EMP-ID          PIC X(8).
           05  TR-HOURS           PIC S9(3)V99 COMP-3.
           05  TR-RATE            PIC S9(5)V99 COMP-3.
           05  TR-TYPE            PIC X.
               88  TR-REGULAR     VALUE 'R'.
               88  TR-OVERTIME    VALUE 'O'.
       01  WS-TRANS-STATUS        PIC XX.
           88  TRANS-OK           VALUE '00'.
           88  TRANS-EOF          VALUE '10'.

           PERFORM UNTIL TRANS-EOF
               READ TRANS-FILE INTO WS-TRANS-REC
               EVALUATE TRUE
                   WHEN TRANS-OK
                       IF TR-HOURS IS NUMERIC AND TR-RATE IS NUMERIC
                           PERFORM 2000-CALC-PAY
                       ELSE
                           PERFORM 8000-REJECT-RECORD
                       END-IF
                   WHEN TRANS-EOF
                       CONTINUE
                   WHEN OTHER
                       PERFORM 9000-IO-ERROR
               END-EVALUATE
           END-PERFORM
A record layout with packed fields and 88-level conditions, and a read loop driven by file status. Not executed; shown for the layout and the NUMERIC check that prevents a data exception.

JCL questions

//PAYRUN   JOB (ACCT),'NIGHTLY PAY',CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID
//*  Step 1: sort transactions by employee id
//SORTSTEP EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=PROD.PAY.TRANS.DAILY,DISP=SHR
//SORTOUT  DD DSN=&&SORTED,DISP=(NEW,PASS),
//            SPACE=(CYL,(10,5)),UNIT=SYSDA
//SYSIN    DD *
  SORT FIELDS=(1,8,CH,A)
/*
//*  Step 2: run only when the sort returned 0
//         IF (SORTSTEP.RC = 0) THEN
//PAYSTEP  EXEC PGM=PAYCALC
//STEPLIB  DD DSN=PROD.PAY.LOADLIB,DISP=SHR
//TRANSIN  DD DSN=&&SORTED,DISP=(OLD,DELETE)
//PAYOUT   DD DSN=PROD.PAY.RESULTS(+1),
//            DISP=(NEW,CATLG,DELETE),
//            SPACE=(CYL,(20,10),RLSE),UNIT=SYSDA,
//            RECFM=FB,LRECL=200
//SYSOUT   DD SYSOUT=*
//         ENDIF
A two-step batch job: sort the day's transactions into a temporary dataset, then run the pay program only if the sort ended cleanly, writing a new generation of a GDG. Not executed; names are made up.
  • What are the three main JCL statements? JOB identifies the job and its accounting and class, EXEC runs a program or a procedure, and DD connects a program's file name to a dataset or output.
  • Explain DISP=(NEW,CATLG,DELETE). Status, normal end and abnormal end: create the dataset, catalog it if the step ends normally, delete it if the step abends. SHR allows shared reading; OLD takes exclusive use.
  • What is a GDG and what do (0) and (+1) mean? A generation data group keeps numbered versions of a dataset under one base name with a limit. (0) is the current generation and (+1) creates the next one, which becomes (0) after the job ends.
  • COND parameter versus IF/THEN/ELSE? Both skip steps based on earlier return codes. COND reads backwards (the step is bypassed when the test is true), which is why many shops prefer IF/THEN for readability.
  • What is a PROC and how do you override it? A catalogued or in-stream procedure of reusable steps. Symbolic parameters change values, and DD overrides in the calling JCL (stepname.ddname) replace or add datasets for one run.
  • What do STEPLIB and JOBLIB do? They name load libraries searched for the program before the system's link list, for one step or the whole job.
  • How do you restart a job from a failed step? With RESTART on the JOB statement (or through the scheduler), after checking which datasets the failed step created or half-wrote and cleaning them up first.
  • What does TYPRUN=SCAN do? It checks the JCL for syntax errors without running it.

Abends and return codes

The codes production support interviews ask about most
CodeUsual meaningWhat you would check
S0C7Data exception: arithmetic on a field that does not hold valid packed or zoned decimalThe offset in the dump or listing, the record that was being processed, and whether spaces or low-values reached a numeric field. Add NUMERIC checks or fix the input.
S0C4Protection exception: the program touched storage it does not ownSubscripts or indexes out of range, a bad LINKAGE layout against the caller's data, or a file accessed before OPEN.
S322The job or step used more CPU time than allowedA loop that never ends, or a TIME limit too small for a larger volume.
SB37, SD37, SE37Out of space in different waysPrimary and secondary allocations, the volume count, and whether the dataset or the PDS directory needs more room.
S806The program could not be foundThe program name, STEPLIB or JOBLIB, and whether the load module was promoted to that library.
S222The job was cancelled, usually by an operator or the schedulerWho cancelled it and why, often a wait on a dataset or a long run.
User abends (Unnnn)Raised by the application or a runtimeThe shop's or product's documentation for that number; meanings are not universal.
The codes production support interviews ask about most. Scroll sideways on a small screen.
def unpack_comp3(raw: bytes, scale: int = 0):
    """Decode a COBOL COMP-3 (packed decimal) field: two digits per byte,
    the last half-byte is the sign (C or F positive, D negative)."""
    nibbles = []
    for byte in raw:
        nibbles += [byte >> 4, byte & 0x0F]
    sign = nibbles.pop()
    if any(n > 9 for n in nibbles) or sign not in (0xC, 0xD, 0xF):
        raise ValueError("invalid packed data")      # what an S0C7 abend is about
    value = int("".join(map(str, nibbles)))
    if sign == 0xD:
        value = -value
    return value / 10**scale if scale else value


def pack_comp3(value: int, digits: int) -> bytes:
    """Encode an integer as packed decimal with an odd digit count, e.g. PIC S9(7) COMP-3."""
    text = str(abs(value)).rjust(digits, "0") + ("D" if value < 0 else "C")
    return bytes.fromhex(text)


# PIC S9(5)V99 COMP-3 holding -12345.67 occupies 4 bytes: 12 34 56 7D
field = pack_comp3(-1234567, 7)
print(field.hex().upper(), unpack_comp3(field, scale=2))    # 1234567D -12345.67
print(len(pack_comp3(0, 7)), "bytes for 7 digits")          # 4 bytes for 7 digits

try:
    unpack_comp3(b"\x40\x40\x40\x40")                   # EBCDIC spaces where a number should be
except ValueError as e:
    print(e)                                                # invalid packed data
What a COMP-3 field looks like in bytes, and why spaces in a numeric field cause an S0C7. Runs with Python 3, no libraries.

DB2, CICS and VSAM questions

Intermediate questions on the data and online side
QuestionWhat a strong answer shows
What do SQLCODE 0, 100, -803, -811 and -911 mean?0 success, 100 no row found or end of cursor, -803 duplicate key on insert or update, -811 a singleton SELECT returned more than one row, and -911 a deadlock or timeout that rolled the unit of work back.
What does -805 or -818 tell you?The program and its DB2 package do not match: -805 the package was not found in the plan, -818 the load module and the bound package came from different precompiles. Usually a promotion or bind step was missed.
What is precompile, BIND, a package and a plan?The precompiler pulls SQL out of the COBOL source into a DBRM. BIND turns that into a package with access paths, and a plan lists the packages a program can use at run time.
Why declare a cursor WITH HOLD?So it stays open across a COMMIT, which a long batch program needs when it commits every few thousand rows.
Why commit periodically in batch, and what does it change?To release locks and limit how much work a failure rolls back. It means the program needs restart logic that knows the last committed key.
What is a null indicator?A small host variable paired with a nullable column. A negative value means the column was null, and fetching a null without one fails.
What is DCLGEN?A tool that generates a COBOL layout and table declaration from a DB2 table, so the program and table agree.
What is pseudo-conversational CICS, and why use it?The transaction ends after sending a screen and restarts when the user responds, passing state in a COMMAREA or channel. Resources are not held while a person is thinking.
What do EIBCALEN and the COMMAREA tell a program?A zero EIBCALEN means first entry with no state passed, so show the initial screen; otherwise the COMMAREA carries the conversation's state.
KSDS, ESDS and RRDS?VSAM key-sequenced (access by key, the most common), entry-sequenced (in arrival order, like a log) and relative-record (by slot number). IDCAMS defines and manages them.
What are CI and CA splits, and why do they matter?When an insert does not fit, VSAM splits a control interval or a whole control area, which slows access. Free space settings and reorganizing the file reduce them.
Intermediate questions on the data and online side. Scroll sideways on a small screen.

Senior and production support scenarios

  • A nightly job abends with S0C7 at 2 a.m. and the downstream jobs are waiting. Walk me through it. Find the failing statement from the abend offset and the compile listing, identify the record from the dump or a DISPLAY, decide with the business whether to fix the data, skip the record or hold the cycle, then restart from the right step and add a NUMERIC check so it is rejected cleanly next time.
  • A DB2 batch step keeps failing with -911 when it overlaps an online window. Lock contention. Commit more often, access rows in a consistent order, check whether the step escalates to table locks, and talk to scheduling about moving it.
  • A job that took twenty minutes now takes three hours. Compare volumes first. Then look for a changed access path after a rebind, missing statistics, VSAM splits, or a sort that now spills to work datasets.
  • How do you design a restartable batch program? Commit at intervals and save the last processed key in a checkpoint table, so a restart skips work already done instead of duplicating postings.
  • How do you promote a change safely? Compile and link through the shop's change tool, bind the DB2 package in each environment, test with production-like volumes, and keep a back-out plan for load modules and binds.
  • What does modernization look like in practice? Usually not a big-bang rewrite. Teams expose CICS or batch functions as APIs, move reporting data off the platform, add Git-based tooling and automated tests, and rewrite pieces where the business case is clear.
  • How do batch schedulers fit in? Tools such as Control-M, CA-7 or IBM's workload scheduler run jobs by time and dependency, handle restarts and alert on failures. Know how your scheduler marks a job complete or forces it.

Fictional example

Answering "A file status 35 stopped the cycle. What do you do?"
Interviewer
The billing job failed at OPEN with file status 35 on its input file. Operations is asking how long the fix will take.
Candidate
Status 35 means the file was not there when the program opened it, so I would start with the JCL and the job log, not the program. I would check the DD name matches the SELECT in the program, then whether the dataset name is right and cataloged. If it is a GDG, the usual cause is an upstream job that did not create today's generation, or ran late, so the relative number points to nothing. I would look at the scheduler for the predecessor, rerun it if it failed, and restart billing from the failed step. I would tell operations what I found and an estimate within fifteen minutes, and afterwards suggest adding the dependency to the schedule if it was missing.

How to prepare for a mainframe interview

  1. Know storage by heartBytes for DISPLAY, COMP and COMP-3 fields, sign handling, and why spaces in a packed field abend.
  2. Write JCL from memoryA job with a sort, a program step, a GDG output, a temporary dataset and a conditional step, then explain every DISP.
  3. Learn the codes as storiesFor each common abend and SQLCODE, prepare one real or practice incident: what failed, what you checked and how you restarted.
  4. Practice online and data questionsPseudo-conversational CICS, COMMAREA, cursors with commits, binds and packages.
  5. Get hands-on if you canIBM has offered free learning systems for z/OS skills; check its current programs. GnuCOBOL on a laptop is enough to practice the language itself.

Production support answers are judged on order: what you checked first and when you told people. Natively, an AI interview assistant for Mac and Windows, transcribes your mock rounds on the computer so you can read back whether you jumped to a fix before reading the job log. In practice it can suggest answers live and read a JCL listing or an abend message from a screenshot. Add your résumé and the job description (Pro or the free trial) and suggestions follow the shop's stack, and the transcript and notes stay available for review.

Questions people ask

What mainframe questions are asked in interviews?

COBOL divisions, PIC clauses and COMP-3, REDEFINES and tables, JCL statements, DISP and GDGs, condition codes and restart, common abends such as S0C7 and S0C4, DB2 SQLCODEs, binds, CICS pseudo-conversational design and VSAM file types.

What is an S0C7 abend?

A data exception: the program did arithmetic or a numeric compare on a field that does not hold valid packed or zoned decimal data, often spaces or low-values in a numeric field. Find the record and add NUMERIC checks.

What does SQLCODE -911 mean in DB2?

The unit of work was rolled back because of a deadlock or a lock timeout. Committing more often, accessing rows in a consistent order and avoiding overlap with online work usually help.

Are mainframe interviews for freshers different?

Freshers are usually asked COBOL and JCL theory, often after company training, with simple programs and definitions. Experienced candidates get production support scenarios, DB2 and CICS depth and performance questions.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP