Part V: Enterprise Data Access

Chapters 22--26


There is a reason that COBOL developers who know DB2, CICS, and IMS command the highest salaries in the enterprise programming world. These three technologies -- IBM's relational database, online transaction processing system, and hierarchical database/message queuing system -- form the core of the IBM enterprise stack that powers the world's largest banks, insurance companies, government agencies, and retailers. A COBOL developer who can write batch programs that process files is useful. A COBOL developer who can write embedded SQL to query and update DB2 databases, build CICS transactions that serve thousands of concurrent users, and navigate IMS hierarchical databases has skills that are in critical demand and extraordinarily short supply.

Part V takes you into this enterprise stack. Over five chapters, you will learn to embed SQL statements in COBOL programs for full relational database access through DB2, design and build CICS online transactions that respond to user input in real time, work with advanced DB2 features including cursors, dynamic SQL, and stored procedures, master the advanced CICS patterns of pseudo-conversational programming and BMS screen mapping, and navigate the IMS hierarchical database model that predates relational databases and remains in production at many of the world's largest institutions.

A candid note is necessary here: these are IBM-specific technologies. DB2 for z/OS, CICS, and IMS run on IBM mainframes, and there are no direct open-source equivalents that replicate their full functionality. GnuCOBOL can connect to relational databases through ODBC and ESQL interfaces, and some of the SQL concepts translate to PostgreSQL or MySQL, but the CICS and IMS material has no meaningful desktop substitute. For hands-on practice with these technologies, we strongly recommend enrolling in IBM Z Xplore (formerly Master the Mainframe), which provides free access to a real z/OS system with DB2, CICS, and IMS available. Several of the exercises in Part V are designed to be completed on the Z Xplore platform.

That said, even if you study this material purely from the textbook without hands-on access, the knowledge you gain will be immensely valuable. Interview questions for mainframe COBOL positions invariably cover DB2 and CICS. Understanding the architecture, the programming patterns, and the operational concepts puts you ahead of candidates who have never been exposed to these technologies.


What You Will Learn

Part V covers the three pillars of IBM enterprise data access: DB2 for relational data, CICS for online transactions, and IMS for hierarchical data and message processing. These technologies are not competitors -- they are complementary components of an integrated enterprise platform. A single business transaction might involve a CICS program calling a COBOL subprogram that queries DB2 for customer data, reads an IMS database for historical records, and writes to a VSAM file for batch processing later that evening.

Understanding how these components work together, and where each is appropriate, is the knowledge that distinguishes a senior mainframe developer from a junior one. Part V gives you the foundation for that understanding.


Chapter Summaries

Chapter 22: Embedded SQL and DB2 Fundamentals

DB2 is IBM's relational database management system for z/OS, and embedded SQL is the mechanism by which COBOL programs interact with it. Chapter 22 introduces the fundamentals: the EXEC SQL...END-EXEC syntax for embedding SQL statements in COBOL source code, the DB2 precompiler process that translates embedded SQL into COBOL CALL statements before the COBOL compiler runs, and the SQLCA (SQL Communication Area) that returns status information after every SQL operation. You will learn to declare host variables that bridge COBOL data items and DB2 columns, write SELECT INTO statements for single-row retrieval, use INSERT, UPDATE, and DELETE for data modification, and handle the SQLCODE values that indicate success, not-found, duplicate-key, and error conditions. The DCLGEN utility, which generates COBOL copybooks from DB2 table definitions, is covered as the standard practice for keeping COBOL data definitions synchronized with database schemas. Null handling with indicator variables, data type mapping between COBOL PICTURE clauses and DB2 column types, and the COMMIT/ROLLBACK statements for transaction control complete the foundational material. The chapter includes a complete DB2 program that demonstrates the full lifecycle: connect, query, process, update, commit, and disconnect.

Chapter 23: Advanced DB2 Programming

Real-world DB2 programming extends well beyond single-row queries. Chapter 23 covers the advanced DB2 techniques that production COBOL programs require. Cursors are the primary focus: DECLARE CURSOR with SELECT, OPEN, FETCH, and CLOSE for processing multi-row result sets, with attention to cursor types (scrollable, holdable, updateable) and the FETCH loop patterns that interact with COBOL's PERFORM UNTIL. Positioned UPDATE and DELETE operations using WHERE CURRENT OF CURSOR are covered for modifying data row by row during cursor processing. Dynamic SQL, which constructs SQL statements at runtime from program variables, is introduced for situations where the query structure is not known at compile time. The chapter covers DB2 program preparation in detail: the precompile, bind, compile, and link-edit steps that transform a COBOL program with embedded SQL into an executable load module with an associated DB2 package or plan. Performance considerations receive significant attention: the impact of access path selection, the importance of predicate design for efficient index usage, the cost of cursor operations, and the techniques for minimizing DB2 overhead in high-volume batch programs. Stored procedures written in COBOL, which execute within the DB2 address space for reduced overhead, are introduced as an advanced pattern for database-intensive operations.

Chapter 24: CICS Fundamentals

CICS (Customer Information Control System) is the online transaction processing environment where COBOL programs serve real-time user requests. Chapter 24 introduces the CICS programming model, which differs fundamentally from batch programming. In CICS, your COBOL program does not control the flow -- CICS controls it. Your program is loaded and invoked by CICS in response to a transaction request, it processes the request using CICS API commands (EXEC CICS...END-EXEC), and it returns control to CICS when finished. The chapter covers the CICS SEND and RECEIVE commands for terminal communication, the EXEC CICS READ, WRITE, REWRITE, and DELETE commands for VSAM file access through CICS, the concept of the CICS Task Control Area and the Execute Interface Block (EIB) that provides runtime information, and the HANDLE CONDITION and RESP options for error handling. You will learn about the CICS program lifecycle: how programs are defined to CICS, how transactions trigger program execution, how the COMMAREA (Communication Area) passes data between programs, and how CICS manages the resources (files, queues, terminals) that your programs access. Basic screen output using SEND TEXT and formatted screens are introduced, establishing the foundation for the BMS mapping covered in Chapter 25.

Chapter 25: Advanced CICS Programming

Production CICS applications use programming patterns that are significantly more sophisticated than basic send-and-receive. Chapter 25 covers the advanced CICS techniques that distinguish professional online COBOL development. Pseudo-conversational programming is the central topic: the pattern where a CICS program sends a screen to the user, returns control to CICS (freeing its resources), and is reinvoked when the user responds -- with state preserved in the COMMAREA between interactions. This pattern is essential because CICS cannot afford to hold resources for the seconds or minutes that a user takes to read a screen and type a response. BMS (Basic Mapping Support) is covered in depth: defining maps and mapsets with BMS macros, generating symbolic maps as COBOL copybooks, sending and receiving mapped screens, cursor positioning, attribute manipulation, and the patterns for building multi-screen applications with menus, data entry forms, and browse displays. The chapter covers CICS program-to-program communication using LINK (synchronous call) and XCTL (transfer of control), temporary storage queues for inter-transaction data sharing, transient data queues for asynchronous processing, and the START command for scheduling delayed transactions. CICS and DB2 integration is addressed, showing how a CICS COBOL program can execute embedded SQL within the CICS environment, combining online transaction processing with relational database access. Error handling in CICS, including HANDLE ABEND, RESP/RESP2 checking, and journaling for recovery, completes the chapter.

Chapter 26: IMS Database and Transaction Management

IMS (Information Management System) is IBM's hierarchical database and transaction processing system. Older than DB2 and CICS, IMS remains in production at many of the world's largest financial institutions and government agencies, managing data that was first loaded decades ago and has been continuously maintained ever since. Chapter 26 covers both IMS DB (the hierarchical database) and IMS TM (the transaction manager). The IMS database model organizes data into hierarchical segments arranged in parent-child relationships -- a model that is intuitive for naturally hierarchical data like organizational structures, bills of materials, and account-transaction histories. You will learn DL/I (Data Language/I), the call-level interface for IMS database operations: GU (Get Unique), GN (Get Next), GNP (Get Next within Parent), ISRT (Insert), REPL (Replace), and DLET (Delete) calls, each invoked through COBOL CALL statements with a PCB (Program Communication Block) and an SSA (Segment Search Argument). The chapter covers IMS database navigation -- the concept of position within the hierarchy and how successive DL/I calls move through the database -- which is fundamentally different from SQL's set-oriented query model. IMS TM as a CICS alternative for online transaction processing is briefly covered, along with the MFS (Message Format Service) for terminal I/O. The relationship between IMS and DB2, including the common pattern of IMS databases being accessed alongside DB2 tables in the same application, is addressed.


Learning Objectives

Upon completing Part V, you will be able to:

  • Write COBOL programs with embedded SQL that query, insert, update, and delete data in DB2 tables, using host variables, SQLCA checking, and proper SQLCODE handling
  • Process multi-row result sets using DB2 cursors with DECLARE, OPEN, FETCH, and CLOSE, including positioned updates and deletes
  • Build CICS online transactions that communicate with terminals using SEND/RECEIVE, access VSAM files through CICS commands, and handle errors using RESP options
  • Implement pseudo-conversational CICS programs that preserve state across user interactions using the COMMAREA, and design BMS-mapped screens for professional terminal interfaces
  • Navigate IMS hierarchical databases using DL/I calls (GU, GN, GNP, ISRT, REPL, DLET) and understand the segment hierarchy, SSA qualification, and database positioning concepts
  • Understand the DB2 program preparation process including precompile, bind, compile, and link-edit steps, and interpret DB2 diagnostic messages and SQLCODE values
  • Integrate DB2, CICS, and IMS within a single application architecture, understanding where each technology is appropriate and how they complement each other
  • Articulate the differences between batch and online programming models, between relational and hierarchical database access, and between CICS and IMS transaction management

Why These Skills Are the Most In-Demand

A straightforward observation about the COBOL job market: the positions with the highest compensation and the most acute shortage of candidates are those requiring DB2, CICS, and IMS experience. Industry surveys consistently show that:

  • Over 70% of mainframe COBOL job postings mention DB2 as a required or preferred skill
  • Over 50% mention CICS experience
  • Positions requiring IMS experience often remain open for months due to the extreme scarcity of qualified candidates
  • Candidates with combined COBOL/DB2/CICS skills command salary premiums of 20--40% over candidates with COBOL-only experience

The reason is straightforward: these technologies are deeply embedded in the most critical business systems, and the developers who understand them are retiring faster than they can be replaced. A bank that needs someone to modify a CICS transaction that accesses DB2 and IMS cannot hire a general-purpose programmer and hope for the best. They need someone who understands all three technologies and how they interact. Part V begins building you into that someone.


Platform Considerations and Hands-On Access

DB2, CICS, and IMS are IBM mainframe technologies. While the COBOL language itself is platform-independent, the enterprise data access techniques covered in Part V are specific to the IBM z/OS environment. This creates a practical challenge for self-study: you need access to a mainframe to practice these skills hands-on.

Several options are available:

IBM Z Xplore (formerly Master the Mainframe): IBM's free learning platform provides access to a real z/OS system with DB2, CICS, and development tools. This is the recommended option for Part V hands-on exercises. Registration is free and available worldwide at ibm.biz/zxplore.

IBM Z Trial: A cloud-based z/OS environment for evaluation and development, available with a free trial period.

Employer-provided access: If you are studying COBOL for a specific employer, they may provide access to their development mainframe or a training LPAR (logical partition).

GnuCOBOL with ODBC: For the DB2 chapters, GnuCOBOL can connect to PostgreSQL or MySQL through ODBC, and many SQL concepts transfer. The specific EXEC SQL syntax will differ, but the programming patterns are similar. The exercises note GnuCOBOL alternatives where feasible.

Conceptual study: Even without hands-on access, reading the chapters, studying the code examples, and completing the paper-based exercises provides substantial value. Many developers have passed mainframe job interviews based on textbook knowledge before getting their first hands-on mainframe access from their employer.


Prerequisites

Part V assumes mastery of Parts I through IV (Chapters 1--21):

  • Complete COBOL program structure and data definition
  • All file organizations (sequential, indexed, relative) with comprehensive FILE STATUS handling
  • Control flow, string handling, and table processing
  • Subprogram design with CALL, LINKAGE SECTION, and parameter passing
  • Copybook creation and management using the COPY statement
  • Debugging techniques and professional coding standards
  • Basic JCL for program compilation and execution

The subprogram architecture from Chapter 17 is particularly important for CICS programming, where programs are invoked as called modules. The copybook practices from Chapter 18 are essential for DB2 programming, where DCLGEN-generated copybooks are the standard mechanism for host variable definition. The debugging techniques from Chapter 20 will be applied in new ways when you encounter DB2 SQLCODE errors and CICS abends.


How the Chapters Build on Each Other

The five chapters of Part V are organized in two tracks that converge:

  1. Chapter 22 (DB2 fundamentals) introduces relational database access -- the most commonly required enterprise skill
  2. Chapter 23 (advanced DB2) deepens the DB2 coverage with cursors, dynamic SQL, and performance optimization
  3. Chapter 24 (CICS fundamentals) introduces online transaction processing -- a distinct programming model from batch
  4. Chapter 25 (advanced CICS) builds on Chapter 24 with pseudo-conversational programming, BMS, and CICS-DB2 integration, connecting the DB2 track with the CICS track
  5. Chapter 26 (IMS) introduces the hierarchical database model, which complements both DB2 and CICS and is often encountered alongside them

The recommended study order is the chapter sequence as presented. Chapters 22--23 form a pair (DB2), Chapters 24--25 form a pair (CICS), and Chapter 26 (IMS) draws on concepts from both pairs. If your career interest or employer focus is exclusively on one technology, you may prioritize that pair, but we recommend completing all five chapters for a comprehensive understanding of the enterprise stack.


Estimated Study Time

Plan for approximately 55 to 70 hours to work through Part V. This is the second most time-intensive part of the textbook (after Part III), reflecting the depth and complexity of enterprise data access technologies.

  • Chapter 22 (DB2 fundamentals): 10--12 hours, including SQL practice
  • Chapter 23 (advanced DB2): 12--14 hours, including cursor programming and bind process
  • Chapter 24 (CICS fundamentals): 10--12 hours, including transaction design
  • Chapter 25 (advanced CICS): 12--16 hours, including BMS map creation and pseudo-conversational programming
  • Chapter 26 (IMS): 8--12 hours, including DL/I call practice

If you have prior experience with SQL from other databases, Chapters 22 and 23 may go faster. If you have experience with web application frameworks, the concepts of request-response processing in CICS may feel familiar. If you have neither, budget for the longer estimates. IMS (Chapter 26) is often the most conceptually challenging for developers accustomed to relational databases, because the hierarchical model and navigational access pattern require a different way of thinking about data.


What Mastery of Part V Enables

Completing Part V transforms your career profile. You are no longer a COBOL programmer -- you are a mainframe application developer with enterprise data access skills. This distinction is not semantic; it represents a qualitative difference in the positions you qualify for, the compensation you can command, and the problems you can solve.

With Parts I through V complete, you can:

  • Design and develop batch COBOL programs that process files and access DB2 databases
  • Build online CICS transactions that serve real-time user requests with professional terminal interfaces
  • Navigate and update IMS hierarchical databases
  • Integrate DB2, CICS, IMS, and VSAM within unified application architectures
  • Participate meaningfully in conversations about mainframe application design and modernization

Part VI (Mainframe Environment and Batch Processing) will deepen your understanding of the z/OS operating environment -- JCL mastery, batch processing patterns, mainframe utilities, and system administration -- providing the operational context for the enterprise applications you can now develop. Part VII (Financial Systems) will show you how the skills from Part V are applied in the banking, insurance, and accounting domains where COBOL does its most critical work.

The enterprise data access skills from Part V are the skills that employers pay premium salaries for, that keep systems running, and that cannot be easily automated or outsourced. They are hard to learn precisely because they require understanding not just a language but an entire integrated technology platform. You have now begun that understanding. The rest is practice and experience.


"The best way to predict the future is to implement it." -- David Heinemeier Hansson (adapted)

Turn to Chapter 22 and connect your COBOL programs to the enterprise.

Chapters in This Part