Editing a BMS Mapset | Joins |
Use Host Compatibility Option, together with IBM's DB2 database system, to include a DB2 application in a Mainframe Express project. You can also maintain a DB2 UDB database using a set of interactive tools. Alternatively, you can connect to an existing mainframe DB2 database using IBM's DB2 Connect product. You can compile, edit and debug your DB2 application in a DB2 environment on your PC.
SQL Option and Host Compatibility Option are alternative facilities for handling a DB2 application. See the chapter DB2 Applications (SQL Option) for a session using SQL Option.
You need to have read the chapter Start Here for the Tutorials and worked through the first session, Using Mainframe Express, before you do this session.
You need to have installed Host Compatibility Option to do this session. Note that Setup will only have offered you the option to install Host Compatibility Option if you ran it with the /hco command line parameter. Otherwise it will have offered SQL Option instead.
We assume you are familiar with DB2 on a mainframe.
You must also have IBM's DB2 Universal Database system installed.
Host Compatibility Option is a set of tools that enable you to do DB2/MVS and DB2/VM development and testing on your PC using some of IBM's family of DB2 Universal Database products.
This session takes you through maintaining and running an DB2 application on your PC.
The demo application used in this session is a simple DB2 application that you might have downloaded from a mainframe. In this session, you get it working on your PC.
In the following, if you need to open the DB2 Command Window, do so by clicking Start, then Programs, then DB2, then Command Window.
db2start
db2 drop db db2demo
If this tutorial has not in fact been run before, this command results in a message saying the database cannot be found. You can ignore this message.
In this session you:
To create the project:
You now get a page asking which of the installed options this project uses.
Because you have said this project uses SQL, and you installed Host Compatibility Option (rather than SQL Option), you now get a page asking the name of the DB2 database.
To add your files to the project:
The files are added to the project.
You must create a database before you can do anything else. The database is where all tables are defined and data stored.
The Create Database dialog box appears.
A new tab has appeared in the Output window, displaying the Host Compatibility Option log. It has a tab HCO Log.
If this session has been run before, and you did not delete the database while following the section Preparation above, the log will include a message that the database alias "DB2DEMO" already exists. You can ignore this messsage.
You use the supplied DDL file to add the table and data.
The DDL Processor Tool appears. It auto-connects to the database DB2DEMO specified in the project.
This sets the DDL File field to the name of this file.
The log file is displayed in the HCO Log view of the Output window. Don't worry if it shows a non-zero return code. The DDL starts with some DROP TABLE statements to delete these tables if they have been created previously. These statements will return non-zero codes if you are running the demo from scratch.
We need to import some data into the table. We will import data into the DEMO.PRODUCT table from a file that has data stored in DSNTIAUL format.
The Import Data Tool appears. It auto-connects to the database DB2DEMO specified in the project.
This sets the Import from field to the name of this file.
The log file is displayed in the HCO Log view of the Output window.
To generate a COBOL copybook:
The Generate Copybook Tool appears. It auto-connects to the database DB2DEMO specified in the project.
We will generate a copybook that has the table name as prefix for all host variables.
In the Save dialog box that appears, notice that items.cpy is ready selected.
The copybook is displayed in the HCO Log view of the Output window.
To generate an alias for a table in the database:
The Generate Alias Tool appears. It auto-connects to the database DB2DEMO specified in the project.
In the Save dialog box that appears, notice that genalias.sql is ready selected.
The ALIAS DDL statements created are displayed in the HCO Log view of the Output window.
If you accidentally closed the Generate Alias Tool, don't worry. Just repeat from the beginning of this Generating an Alias section.
Notice that the on the toolbar is now enabled (no longer grayed out). Now that you have created the ALIAS DDL statements, you use the DDL processor to run the DDL that actually creates the ALIASes. It is a two step process, since a Database Administrator may want to change the DDL to make it generic.
The Generate Alias Tool closes and the DDL Processor Tool opens. It auto-connects to the database DB2DEMO specified in the project.
You can now generate DDL using the aliases just created.
This sets the DDL File field to the name of this file.
The log file is displayed in the HCO Log view of the Output window.
To build the project:
The build finishes with "Build finished with no errors".
The COBOL programs in this application expect the tables to have a prefix of DEMO. In fact Host Compatibility Option by default used your user ID (which you specified the first time you started Mainframe Express - see the chapter Using Mainframe Express) as the prefix when creating the table. However, this works because we created aliases with the DEMO prefix.
If you did not want to create the aliases, you would have had to set the DEMO prefix in the build settings. To do this, you would click COBOL in the left-hand pane, then the Project menu, then Build settings for COBOL, then the Preproc tab, then click by Exec SQL to put a check mark there, then click the More button to the right of Exec SQL, then enter DEMO in the Implicit Qualifier field.
To run the application:
The application runs. The Application Output window appears and displays the screen output from the application. The application displays a list of products, taken from the PRODUCTS table in the database.
If you get a "***" line indicating more input is required, just press Enter to let the application complete.
You can run the application in the same way using hcobatch.jcl instead of hcodyn.tso.
The sections so far in this session created the database and then built and ran the application. Let's now look at a few more tools you can use on your database without you needing to create an application.
To export data from a table
The Export Data Tool appears. It auto-connects to the database DB2DEMO specified in the project.
In the Save dialog box that appears, notice that product.ixf is ready selected.
The log file is displayed in the HCO Log view of the Output window.
To execute an SQL Query:
The Query Tool appears. It auto-connects to the database DB2DEMO specified in the project.
This sets the Query listbox to the text of this query.
A new tab has appeared in the Output window, displaying the result of the query. It has a tab HCO Query.
If you accidentally closed the SQL Query Tool, don't worry. Just repeat from the beginning of this Executing an SQL Query section.
You can have the Query Tool explain the query.
An explanation of the query is displayed in the HCO Log view of the Output window.
If you look at the submenu that comes up when you click HCO on the Tools menu in Mainframe Express, you'll see several more tools besides those covered in this session.
Hide the Application Output window and close the project.
You can close DB2 if you wish.
The DB2DEMO database you created in this session is used in several subsequent sessions.
If you want to take a break before going on to the next session, you can close Mainframe Express.
Return to the Tutorials Map in the chapter Start Here for the Tutorials and choose which session to go on to next, depending on your interests.
Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
Editing a BMS Mapset | Joins |