Skip to main content

Problem:

Can a Cobol program CALL a C DLL in Mainframe Express?

Resolution:

This can be done, but you must be aware of some things.

1) C on the PC only comes in character set ASCII (or ANSI ), so the user must

handle EBCDIC to/from ASCII conversions in an intermediary program. This is

best accomplished using a Non-mainframe dialect program in Mainframe

Express (one compiled using the DIALECT(MF) directive). Since the Micro

Focus dialect defaults to use a character set of ASCII, it can pass C the

expected parameters in its native character set, but be aware that one has to

account for both the character set and format of passed parameters (the type

and size of data items) between Cobol and C.

  

2) All DLL's are always loaded by the operating system, not Micro Focus,

so the C DLL must be placed into the PATH environment variable. This action

means a change to the system PATH environmental variable. The easiest way

to accomplish this and not affect the rest of your machine is to go to the

supplied Mainframe Express Command Prompt. From there type ' path '.

Windows will display the current PATH settings. You may see some Micro

Focus directories set multiple times. The order is important and they need

appear only once. (This behavior has to do with the system settings, the

Windows Registry and our request to be added to PATH). Next, copy the

PATH into a .BAT file and add the user directory where the C DLL will reside.

Now, when the user program issues a CALL from Cobol to the C DLL, the C

DLL will be found. One can also issue a CALL to an entry point in a DLL,

but again only from a DIALECT(MF) program. Use a 'SET procedure-ptr to

Entry 'DLLNAME'.

  

And Assembler can also call C, but these apply:

-  Data must be translated when passed back and forth

-  The C DLL must be placed along PATH so the operating system

   can find it since Micro Focus does not load DLLs

-  A Cobol interface routine can be used which can call C.

   This provides maximum flexibility to bypass any AMODE or

   ASCII/EBCDIC issues. Assembler assumes AMODE and a character

   set of EBCDIC, but Cobol can override both of these if needed

   via directives, AMODE and CHARSET, to call C in native pointer

   and ASCII mode. Cobol can translate addresses and codes as

   necessary to interface with existing mainframe Assembler.

Old KB# 2585

#MFDS
#EnterpriseDeveloper