Chapter 1: Using COM and COBOL Together

This chapter explains a bit about COM, what it is, and how Net Express enables you to use it to your advantage. It also describes the use of the Interface Mapper to create a COM component.

The Component Object Model (COM)

COM is a feature of Microsoft Windows which enables an application to expose functionality that can be used by other applications. You can use parts of off-the-shelf packages in conjunction with custom software to create new applications. All of the applications in the Microsoft Office suite and much of the Microsoft BackOffice suite expose their functionality through COM Automation, enabling you to reuse parts of them to perform common functions. For example, if you want your application to generate an attractive looking report and print it, you can use the functionality of Microsoft Word to create and print the report.

Micro Focus COM support enables you to send messages to COM objects from COBOL programs and classes (COBOL as a COM client). You can also create COM objects, enabling you to manipulate a COBOL class through COM Automation.

The terminology used to describe COM components - servers, classes, clients, and objects - can be confusing. In this documentation, we use these terms as follows:

COM is documented in several chapters as follows:

Note: COM clients and objects were formerly known as OLE Automation clients and servers.

The Interface Mapper

You can use the Interface Mapper to create an in-process COM object (.dll). Most of the information you need to do this is presented in the book Interface Mapping Toolkit. When using the Interface Mapper to create your COM object, keep in mind:

To generate a deployable COM object from the interface mapper, right-click the object from the Service Interfaces window and click Deploy on the popup menu. Net Express generates a serviceinterfacename.dll file. This file is located in a subfolder to the folder where your project file (.app) resides, named projectname\repos\serviceinterfacename.deploy. See the Help topic To register an in-process COM object for more information.

This completes the deployment of your COM object; however, you must have your COBOL application running as well for the COM object to access. See the help topic Overview - Running Applications for more information.

Checklist - Before You Start

COM technology is evolving very quickly, and it is possible that not all the third-party software you plan to use for a project supports the functionality you want to use. Before beginning a project, make sure you have up-to-date releases for all third-party software, and that it supports all the functionality you need.

In particular, check the following:

The excel.app project, in folder Examples\Net Express IDE\comdemos\excel, and the word.app project, in folder Examples\Net Express IDE\comdemos\word, demonstrates how COBOL can be used to write a COM client. The readme files (readme.txt) in those folders describe how to run the sample programs.

For More Information

COM is a large subject, and is not covered in depth by a short chapter like this. You might find it helpful to familiarize yourself further with COM. Use the information sources listed below:

You might want to spend some time looking at the COM documents available in Microsoft's MSDN Library.


Copyright © 2006 Micro Focus (IP) Ltd. All rights reserved.