How COBOL-DB2 Compilation Process Works

In Mainframe Programming, it is very important to understand how a COBOL DB2 program is compiled and to be aware of all the important steps in the compilation process.

What is DB2 Pre-Compilation Process in Mainframe

DB2 pre-compilation is one of an important step to prepare a COBOL- DB2 module for execution. COBOL-DB2 module includes SQL statements and Cobol statements. These SQL statements cannot be processed by host language compilers such as COBOL compilers. So a DB2 pre-compiler or DB2 coprocessor is used to process these SQL statements.

In this article, you’ll learn the basic concept of DB2 pre-compilation process. You’ll get an overview of DB2 pre-compiler, DB2 co-processor, DBRM (Database Request Module) and Consistency token. Let’s start with COBOL-DB2 compilation process.

How COBOL-DB2 Compilation Process Works
Photo by olia danilevich on

What is a COBOL DB2 Program

How to compile a COBOL DB2 module or what are the steps which is involved in compiling a COBOL-DB2 program.

A COBOL program that reads or write data to the DB2 database with the help of an SQL statement is known as COBOL DB2 program. COBOL-DB2 Application programs includes various SQL statements to perform many data manipulation operation and SQL statements cannot be processed by host language compiler such as COBOL, C++ orJava. To process these SQL statements, you required either DB2 pre-compiler or DB2 co-processor.

SQL statements processor performs the following actions:

  • It replaces the embedded SQL statements with equivalent calls to DB2 language interface modules.
  • Generate a database request module (DBRM), which will communicate with the embedded SQL requests to DB2 database engine during binding process.

Now, Let’s see how the DB2 pre-compilation process works using a DB2 pre-compiler.

How COBOL-DB2 Compilation Process works

COBOL-DB2 program compilation is a process which is slightly different from normal COBOL program compilation process. It has the below steps in its compilation process:

  • COBOL-DB2 module’s source code is processed by a DB2 pre-compiler. Pre-compiler will generate two outputs (a Modified Source code and Database Request Module (DBRM) consisting of SQL statements).
  • Modified source code is a compiled and link-edit like a simple COBOL program because it does not have any SQL statements. The SQL statements are replaced with an equivalent call to DB2 language interface which is known as DL/I.
  • The Database request modules (DBRMs) are bind into the package or directly into an application plan. The DB2 bind process converts the SQL statement into an executable runtime instruction.

What is DB2 Bind process

DB2 Bind Process is one of the important steps in COBOL DB2 program and it perform 2 important steps as described below:

  1. First, it verifies that your Mainframe ID is authorized to do a bind.
  2. Second, it validates the SQL statement syntax in the program.
  3. Third, DB2 optimizer will turn these SQL statements into an executable code after SQL query optimization. Also, DBRM includes a consistency token to differentiate it from other DBRM which is derived from the other version of the program.

IBM Utilities for Compiling and Binding COBOL DB2 program

IBM Utility program IGYCRCTL is used for compiling COBOL programs and IEWL utility program is used to link edit the program. DSNHPC is the utility to pre-compile and extract the DBRMs. Bind is done using IKJEFT01 utility and its the same utility to execute the COBOL DB2 program as well.

Final Thoughts

In Almost every Mainframe Interview, this is one question that you can expect for sure to test your understanding. I hope this article helps you understand the COBOL DB2 compilation process and overall got a better understanding on how a COBOL DB2 program works.

Leave a Comment

%d bloggers like this: