Preparing an application to run on Db2 for z/OS
To prepare and run applications that contain embedded static SQL statements or dynamic SQL statements, you must process, compile, link-edit, and bind the SQL statements.
Before you begin
To avoid rework, follow these steps:
- Test your SQL statements by using SPUFI.
- Compile your program with no SQL statements, and resolve all compiler errors.
- Proceed with the preparation and the Db2 precompiler or with the host compiler that supports that Db2 coprocessor.
- Applications that contain ODBC calls
- Applications in interpreted languages, such as REXX. For information about running REXX programs, which you do not prepare for execution, see Running a Db2 REXX application.
- Java™ applications, which can contain JDBC calls or embedded SQL statements
About this task
Before you can run an application program on Db2 for z/OS®, you need to prepare it. To prepare the program, you create a load module, possibly one or more packages, and an application plan.
If your application program includes SQL statements, you need to process those SQL statements by using either the Db2 coprocessor that is provided with a compiler or the Db2 precompiler.


- Replace the SQL statements in your source programs with calls to Db2 language interface modules
- Create a database request module (DBRM), which communicates your SQL requests to Db2 during the bind process
- Db2 coprocessor
-
The following figure illustrates the program preparation process when you use the Db2 coprocessor. The process is similar to the process with the Db2 precompiler, except that the Db2 coprocessor does not create modified source for your application program. For more information, see Processing SQL statements by using the Db2 coprocessor.
Figure 1. Overview of the program preparation process for applications that contain embedded SQL. The Db2 coprocessor can combine the precompile and compile steps for certain languages. - Db2 precompiler
-
After you process SQL statements in your source program by using the Db2 precompiler, you create a load module, possibly one or more packages, and an application plan. Creating a load module involves compiling the modified source code that is produced by the precompiler into an object program, and link-editing the object program to create a load module. Creating a package or an application plan, a process unique to Db2, involves binding one or more DBRMs, which are created by the Db2 precompiler, by using the BIND PACKAGE command. For more information, see Processing SQL statements by using the Db2 precompiler.
Procedure
- Processing SQL statements for program preparation
- Compiling and link-editing an application
- Binding application packages and plans
- Running an application on Db2 for z/OS
Binding a package is not necessary in all cases. These instructions assume that you bind some of your DBRMs into packages and include a package list in your plan.
You can use the following methods to complete the program preparation tasks:
- Preparing applications by using JCL proceduresA number of methods are available for preparing an application to run. You can:
- Use Db2 interactive (DB2I) panels, which lead you step by step through the preparation process.
- Submit a background job using JCL (which the program preparation panels can create for you).
- Start the DSNH CLIST in TSO foreground or background.
- Use TSO prompters and the DSN command processor.
- Use JCL procedures added to your SYS1.PROCLIB (or equivalent) at Db2 installation time.
- You can invoke the coprocessor from UNIX System Services. If the DBRM is generated in a HFS file, you can also use the Db2 command line processor to bind the resulting DBRM. Optionally, you can also copy the DBRM into a partitioned data set member by using the oput and oget commands and then bind it by using conventional JCL.
This topic describes how to use JCL procedures to prepare a program. For information about using the DB2I panels, see Preparing an application to run on Db2 for z/OS.
- Preparing applications by the Db2 Program Preparation panels
If you develop programs using TSO and ISPF, you can prepare them to run by using the Db2 Program Preparation panels. These panels guide you step by step through the process of preparing your application to run. Other ways of preparing a program to run are available, but using Db2 Interactive (DB2I) is the easiest because it leads you automatically from task to task.
Important: If your C++ program satisfies both of the following conditions, you must use a JCL procedure to prepare it:- The program consists of more than one data set or member.
- More than one data set or member contains SQL statements.
To prepare an application by using the Db2 Program Preparation panels:- If you want to display or suppress message IDs during program preparation, specify one of the following commands on the ISPF command line:
TSO PROFILE MSGID
- Message IDs are displayed
TSO PROFILE NOMSGID
- Message IDs are supressed
- Open the DB2I Primary Option Menu.
- Select the option that corresponds to the Program Preparation panel.
- Complete the Program Preparation panel and any subsequent panels. After you complete each panel, DB2I automatically displays the next appropriate panel.
- Preparation guidelines for DL/I batch programsUse the following guidelines when you prepare a program to access Db2 and DL/I in a batch program: