RM/COBOL lacks standard ExtFH support for alternate file handlers. However, it supports Btrieve as an available option. RM/COBOL must be configured to use this Btrieve interface to take advantage of RTG. To use the FairCom RTG Btrieve functions, you will replace the Btrieve library reference with a FairCom RTG COBOL library, as described in one of the appropriate sections below.
Windows
The Windows driver is located at:
Driver\ctree.cobol\rm-cobol\mtclient.dll
To install the driver for RM/COBOL on systems running Windows:
Unix/Linux
The Linux driver is located at:
driver\ctree.cobol\rm-cobol\libmtclient.so
To install the RM/COBOL driver on systems running Linux:
Hint: This may be found in two locations. Look in /usr/local/psql/lib as well as /usr/rmcobol.
The RM/COBOL-to-Btrieve Adapter program for Linux, librmbtrv.so (Linux) or WBTRV32.DLL (Windows), is initiated by placing the following configuration record in the RM/COBOL configuration file (see the EXTERNAL-ACCESS-METHOD configuration record for more information on specifying keywords) and starting the RM/COBOL runtime system:
EXTERNAL-ACCESS-METHOD NAME=RMBTRV
Notes:
1) Version 7.1 and later of RM/COBOL for Unix and version 7.5 and later of RM/COBOL for Windows allow a configuration file to be located automatically by the RM/COBOL runtime system, the compiler, and the recovery utility. If the Automatic Configuration File module, librmconfig.so (UNIX) or librmcfg.dll (Windows), is present in the RM/COBOL execution directory, it will be loaded and it will attempt to locate an automatic configuration file. The execution directory on UNIX is normally /usr/bin; on Windows it is normally C:\Program Files\RMCOBOL.
2) If you want a configuration file to by loaded automatically, you need a file named runcobol.cfg (for the runtime system), rmcobol.cfg (for the compiler), or recover1.cfg (for the recovery utility) in the execution directory. If the appropriate file is present, the records in the file will be used to configure the component being executed.
3) The Windows version of RM/COBOL allows configuration files to be physically attached to rmcobol.exe, runcobol.exe, and recover1.exe using the Attach Configuration utility (rmattach.exe). The attached configuration will be processed prior to a configuration file specified by a command-line option. If automatic configuration finds a configuration file, an attached configuration is ignored.
Configuration Options
The following option designates a file to be used as the complete runtime configuration or as a supplement to it and allow suppression of the banner and STOP RUN messages.
Use the C Option to designate a file to be used as the runtime configuration. If the C Option is specified, any attached or automatic configuration is ignored (not processed). The C Option has the following format:
C=pathname
Compression
RM/COBOL enables data compression by default on newly created files. Set <datacompress> to No if you do not want your RM/COBOL files to be compressed:
RUN-INDEX-FILES DATA-COMPRESSION=NO
The RM library must be copied to the local folder where you are running the RM/COBOL runtime.
Place the RM library (for Linux: librmbtrv.so) in the same directory as the RM/COBOL runtime system (runcobol). Typically, the support module is copied into the execution directory (for Linux: /usr/rmcobol, /usr/local/bin, or /usr/bin).
Linux must be able to locate the various executable files that are required. For this support module to be loaded properly, you must make sure that you have set the LD_LIBRARY_PATH environment variable. Add the directory that contains the Pervasive libraries, DSOs (dynamic shared objects), to LD_LIBRARY_PATH. For example:
export LD_LIBRARY_PATH=/usr/local/psql/lib:/usr/lib
Note that if you logged into the system as "psql" these paths will have already been set. To verify that the shared object, librmbtrv.so, is being loaded properly by the RM/COBOL runtime, type the following from the shell command line (for more information about the V option, see Configuration Runtime Command Options):
runcobol xxx -v
If the following line is displayed in the RM/COBOL runtime banner, the RM/COBOL-to-Btrieve Adapter for Linux has been loaded correctly:
$EXEDIR/librmbtrv.so - RM/COBOL Btrieve Adapter - Version n.nn.nn.
The demonstration below shows that it is possible to have an RM/COBOL application that opens some files with the default file system and some files with FairCom RTG WITHOUT any special configuration of FairCom RTG.
The attached sample program creates two files: custmast and itemmast. Run it with RM/COBOL to create these files.
$ runcobol cobol_Tutorial2
INIT
DEFINE
Create table CustomerMaster...
Add records in table CustomerMaster...
Create table ItemMaster...
Add records in table ItemMaster...
MANAGE
Display records...
1000 Bryan Williams
1001 Michael Jordan
1002 Joshua Brown
1003 Keyon Dooling
1 Hammer
2 Wrench
3 Saw
4 Pliers
DONE
Press <ENTER> key to exit . . .
ls *mast*
custmast itemmast
At this point you have an RM/COBOL application that opens multiple files, however you can use FairCom RTG only on one file.
Create a runcobol.cfg file in the execution directory as follows:
echo EXTERNAL-ACCESS-METHOD NAME=RMBTRV32 CREATE-FILES=YES OPTIONS='T=RMBTRV32.log' >runcobol.cfg
Install the FairCom RTG library:
cp whatever/libmtclient.so ./libpsqlmif.so.8
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
Configure FairCom RTG to enable logging so we can see that it is working:
echo \<config\>\<log/\>\</config\> >ctree.conf
$ cat ctree.conf
<config><log/></config>
Start the FairCom RTG server and then re-run the program to check that FairCom RTG is called by noticing the log output with the "missing file" errors (15:12:2):
$ runcobol cobol_Tutorial2
INIT
DEFINEF7FDFAC0> 20160708T115945 api:0324:ctl_init INFO client version:11.3.0.11002-160706 id:34
F7FDFAC0> 20160708T115945 api:4473:ctl_setins INFO server version:11.3.0.11002-160706 id:34
F7FDFAC0> 20160708T115945 core:3091:cts_open ERROR 15:12:2 OPNRFIL(/home/rtguser/rtg.rm/160707/bin.mtc32bitdynamic/custmast.dat,129)
F7FDFAC0> 20160708T115945 core:3091:cts_open ERROR 15:12:2 OPNRFIL(/home/rtguser/rtg.rm/160707/bin.mtc32bitdynamic/itemmast.dat,129)
MANAGE
Display records...
1000 Bryan Williams
1001 Michael Jordan
1002 Joshua Brown
1003 Keyon Dooling
1 Hammer
2 Wrench
3 Saw
4 Pliers
DONE
Press <ENTER> key to exit . . .
Now remove the custmast file and re-run the program to re-create the custmast.dat file with FairCom RTG (notice the "Create table CustomerMaster..." message):
$ rm custmast
$ runcobol cobol_Tutorial2
INIT
DEFINEF7F0DAC0> 20160708T120309 api:0324:ctl_init INFO client version:11.3.0.11002-160706 id:34
F7F0DAC0> 20160708T120309 api:4473:ctl_setins INFO server version:11.3.0.11002-160706 id:34
F7F0DAC0> 20160708T120309 core:3091:cts_open ERROR 15:12:2 OPNRFIL(/home/rtguser/rtg.rm/160707/bin.mtc32bitdynamic/custmast.dat,129)
Create table CustomerMaster...F7F0DAC0> 20160708T120309 core:3091:cts_open ERROR 15:12:2 OPNRFIL(/home/rtguser/rtg.rm/160707/bin.mtc32bitdynamic/custmast.dat,129)
F7F0DAC0> 20160708T120309 core:3091:cts_open ERROR 15:12:2 OPNRFIL(/home/rtguser/rtg.rm/160707/bin.mtc32bitdynamic/custmast.dat,129)
Add records in table CustomerMaster...F7F0DAC0> 20160708T120309 core:3091:cts_open ERROR 15:12:2 OPNRFIL(/home/rtguser/rtg.rm/160707/bin.mtc32bitdynamic/itemmast.dat,129)
MANAGE
Display records...
1000 Bryan Williams
1001 Michael Jordan
1002 Joshua Brown
1003 Keyon Dooling
1 Hammer
2 Wrench
3 Saw
4 Pliers
DONE
Press <ENTER> key to exit . . .
Verify that the file is created with FairCom RTG (file name ends with .dat and .idx extension):
$ ls custmast*
custmast.dat custmast.idx
Now re-run the program to check that it works with both the default file system and FairCom RTG:
$ runcobol cobol_Tutorial2
INIT
DEFINEF7EF3AC0> 20160708T120931 api:0324:ctl_init INFO client version:11.3.0.11002-160706 id:34
F7EF3AC0> 20160708T120931 api:4473:ctl_setins INFO server version:11.3.0.11002-160706 id:34
F7EF3AC0> 20160708T120931 core:3091:cts_open ERROR 15:12:2 OPNRFIL(/home/rtguser/rtg.rm/160707/bin.mtc32bitdynamic/itemmast.dat,129)
MANAGE
Display records...
1000 Bryan Williams
1001 Michael Jordan
1002 Joshua Brown
1003 Keyon Dooling
1 Hammer
2 Wrench
3 Saw
4 Pliers
DONE
Press <ENTER> key to exit . . .
Please notice above that FairCom RTG attempts to open itemmast.dat but it fails with a "missing file" error (15:12:2) so RM/COBOL falls back to use the default file system. You can see that itemmast was opened because the itemmast records are read and displayed (Hammer, Wrench, etc.)