Tuesday, April 23, 2019

z/OS Compiling Programs that Use DB2 or CICS

In our previous article: z/OS Compile Process, we talked of the basic Compile process. On the mainframe though, you can write programs that call other subsystems, like a database system (ie. DB2) or a transaction system (ie. CICS).

That is done by including some statements that these subsystems understand. For DB2, you will include EXEC SQL statements. For CICS, you will include EXEC CICS statements.


Here's an example of a program that calls DB2:


Or if it was a program that uses CICS:


Since these statements are not specific to the programming language being used, these need to be pre-compiled. The pre-compiler will read through the source and then translate these statements into statements that the language can understand.


While DB2 pre-compiles are normally done before the Compile step. You can specify a compile option to have the DB2 pre-compile done within the compile step. This means the compiler will call the DB2 pre-compiler to convert DB2 specific statements to the source language statements before it processes the source code.

CICS compile is done within the compiler step by specifying the CICS option. The compiler is smart enough to translate these CICS statements into the language the compiler understands.

Eliminating DB2 Pre-Compile Step in COBOL and PL/1

As mentioned earlier, you can specify COBOL parameters so the DB2 pre-compile step is executed with the Compile step in your JCL. You do this by adding the SQL parameter in your Compile step.

Since the DB2 precompiler will be executed in your compile step, you need to add a DBRMLIB statement in your Compile step. Shown below is the JCL for a compile step.

//STEPLIB DD DSN=loadlib.where.compiler.resides,DISP=SHR
//DBRMLIB DD DSN=dbrmlib(member),DISP=SHR
//SYSIN     DD  DSN=source.code(member),DISP=SHR
//SYSLIB   DD  DSN=copy.or.inclide.lib,DISP=SHR
//SYSLIN     DD  DSN=&&output,DISP=(,PASS)

Why Execute the DB2 Pre-Compile Step within the Compile Step

By specifying the SQL and CICS options in the compile step, you simplify your compile process. You eliminate the need for a separate JCL to say, compile a pure COBOL program, a COBOL program with DB2 only, COBOL program with CICS only and a COBOL program with DB2 and CICS. You can have only one compile step for all combinations.

No comments:

Post a Comment

Follow by Email

Total Pageviews