Top
NetCOBOL V11.0 Getting Started
FUJITSU Software

A.29 Sample 28: Transaction Management with COM Linkage-MTS

Sample 28 demonstrates COBOL COM server program transaction management using the Microsoft(R) Transaction Server (MTS).

See Chapter 24 in the "NetCOBOL User’s Guide" for details on COBOL application transaction management using MTS.

To use this program, the following products are necessary:

This program accesses a database via the ODBC driver, so the following products are necessary to run this program:

For database access using an ODBC driver, refer to Chapter 19 in the "NetCOBOL User’s Guide".

Overview

As in Sample 25, this sample program provides the following functions for constructing an online store application:

However, this program manages transactions directly from a COBOL program by using the MTS functions.

In Sample 25, the embedded SQL statements COMMIT/ROLLBACK are used and transaction management depends on the database. This is a simple approach for someone who is familiar with embedded SQL statements but increases the database processing load.

This program manages transactions by itself with MTS functions. This reduces the database processing load and enables more detailed transaction management.

There are two methods of using the MTS function for transaction management from a COBOL application:

The first method is shown below.

Available Programs

Applicable COBOL Functions

Applicable COBOL Statements

The IF, INVOKE, INITIALIZE, SET, MOVE, and PERFORM statements are used.

The embedded SQL statements (CONNECT, INSERT, SELECT, UPDATE, ROLLBACK, and DISCONNECT) are used.

Operations Necessary Before Execution

Building and Rebuilding

The Project Manager's build function is used to compile and link this program.

In the screen snapshots below, it is assumed that NetCOBOL was installed in folder C:\NetCOBOL. Change the folder name C:\NetCOBOL to the name of the folder where NetCOBOL is installed on your machine.

  1. Start the Project Manager.

  2. Open the project file SAMPLE28.PRJ.

  3. Check the COM server information.

    Select a target file (STORESV2.DLL) and select "View" from the "Project-Option-COM Server" menu.

    The "View" dialog is opened and the server information can be referenced.

  4. Select "Build" from the "Project" menu.

    After build termination, check that SAMPLE28.DLL is created.

Registering the COBOL Application in MTS

The COBOL application must be registered in the Windows system to use it as a COM server. Also specify a transaction control method in the registration.

Use the MTS explorer to register the COBOL application in the system registry and MTS. For details, refer to the section "Registration in the MTS Environment" in the "NetCOBOL User’s Guide".

Setup the Server Execution Environment

  1. Select "Run-time Environment Setup Tool" from the "Tools" menu of Project Manager.

    The run-time environment setup tool is displayed.

  2. Select "Open" on the "File" menu and create an object initialization file (COBOL85.CBR) in the folder that contains the dynamic link library (SAMPLE28.DLL).

  3. Select the Common tab and enter data as shown below:

    Specify an ODBC information file name in the environment variable @ODBC_Inf (ODBC information file specification).

  4. Click the Apply button.

    The data is saved in the object initialization file.

  5. Select "Exit" on the "File" menu to exit the tool.

Modifying the Client Program

Samples 26 and 27 can be used as clients of this program by modifying them as shown below.