Overview of Interoperability

Microsoft provides the technology for interoperability between native and managed code. They have published much excellent documentation, which explains the options and gives advice on the strategies you can adopt.

Broadly, there are three techniques for calling between native COBOL and managed code (whether managed COBOL or other managed languages):

For native COBOL and managed COBOL to interoperate, you don't need to worry about data type conversion. Native types are understood and converted to the appropriate managed types when the COBOL is compiled.

However, for native COBOL to interoperate with managed code in other languages, the COBOL must use data types that are compatible with those languages. Often there is not a strict one-to-one correspondence between types in different languages and so you need to manipulate the code to ensure compatibility. For example, for integers (such as PIC S9(9) comp-5), you might use the predefined type binary-long, which corresponds to int in both C# and Java.

COM Support from Micro Focus

COM is a feature of Microsoft Windows which enables one application to load and send messages to any application registered with the operating system as a COM Automation server.

Micro Focus COM support enables you to send messages to COM objects from COBOL programs and classes (where this COBOL is behaving 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 class - COBOL class that you write based on existing COBOL programs
  • COM server or COM Automation server - an application created using COM classes
  • COM client - any program that accesses a COM server application
  • COM object or component - an instance of a COM server application received by a client

COM objects are built using Microsoft's Component Object Model (COM). There are two main differences between COM and a language such as native OO COBOL:

  • COM does not support inheritance. When you write a new COM class, you can't inherit functionality from any of your existing COM or non-COM classes.
  • COM does not support class methods and class data.

Microsoft also support a distributed version of COM, which works across a network, called DCOM. DCOM enables you to send messages to an object residing on a different machine.