FairCom RTG COBOL Edition supports Micro Focus COBOL and other dialects through the standard Callable File Handler interface, ExtFH. Refer to your COBOL runtime documentation for specific external file handler configuration.
The client library for Micro Focus is available inside the Driver\ctree.cobol\EXTFH\ folder.
At runtime set the DYNREDIR environment variable to point to the FairCom RTG COBOL Edition driver library as follows:
Windows
set DYNREDIR=CTEXTFH.dll!CTEXTFH
Unix
export DYNREDIR=CTEXTFH.so
When using Micro Focus Visual COBOL for Linux a path can be specified for the DYNREDIR variable.
export DYNREDIR=/usr/local/lib/CTEXTFH.so
When using DYNREDIR with Micro Focus Visual COBOL it is possible to use redirinstance without specifying the library and the func. In this case, the FairCom RTG interface will signal to the COBOL runtime that it does not handle the files and the runtime falls back to the next filesystem specified by DYNREDIR.
When using DYNREDIR, once the CTEXTFH file handler has determined that the file is not in c-tree format, it returns 0 to the COBOL runtime to indicate that it will not perform the I/O operations for the file. Once the COBOL runtime receives 0 from CTEXTFH, the next specified custom file handler in the DYNREDIR, is tried by the COBOL runtime. If no other custom file handler has been specified, the file's I/O operations are processed by the default COBOL File Handler.
There are two methods to instruct Micro Focus COBOL to use the FairCom RTG COBOL Edition file handler:
Compile your programs with the directive:
$set callfh"CTEXTFH"
Link the FairCom DB CTEXTFH.lib library to your program objects. For example:
COBOL –d –g myprogram.obj _CLASS+CTEXTFH+COBINTFN
This causes all COBOL I/O operations to be compiled into calls to FairCom RTG COBOL Edition driver.
Please be aware that the FairCom RTG COBOL Edition driver implements support only for indexed files. If your application uses other types of files, this approach is not viable. Please consider using the alternative Dynamic Redirection approach instead.
To link c-tree as indexed file handler with a COBOL program, you must specify the following flags on the cob command line:
-m ixfile=CTEXTFH to specify ctree as file handler for fixed record length indexed files
-m ixfilev=CTEXTFH to specify ctree as file handler for variable record length indexed files
This ensures that the necessary external references to the ctree library are included in the resulting executable file, and that they are used instead of the default Micro Focus File Handler.
Examples
cob -x prog.cbl -m ixfile=CTEXTFH -m ixfilev=CTEXTFH CTEXTFH.so
When configuring FairCom RTG for Micro Focus on 64-bit AIX systems, you will need to use the following settings:
lib="libcobrts64.so" func="EXTFH"
For example:
<redirinstance lib="libcobrts64.so" func="EXTFH">
...
</redirinstance>
LDR_PRELOAD64=$COBDIR/lib/libcobrts64.so
When Micro Focus COBOL runtime is done using the file-handler, it does not make an EXTFH call (usually before terminating) to de-initialize the file-handler. We used to de-initialize c-tree at file close or at transaction end when there were no more open files and no running transactions. This released c-tree resources as soon as possible including the file pool and memory files. When a new file was opened, c-tree re-initialized.
Now a new strategy has been implemented by detecting the library loading and unloading and de-initializing c-tree at library unload. This new behavior is now the default and can be controlled by the new configuration keyword <extfhexit>.