Skip to content

IBM(R) DB2(R)

Due to the high level of compatibility with Micro Focus that COBOL-IT provides with its MF command line emulator cobmf, current documentation provided by DB2 for use with Micro Focus COBOL can be used by COBOL-IT users, with just a few adjustments, documented below.

cobmf - the COBOL-IT MF Command-line Emulator

cobmf, or cobmf.exe in Windows environments, is located in the $COBOLITDIR\bin directory. For a full list of compiler flags supported by cobmf, just type cobmf [return] at the command line.

cobmf facilitates the transition from Micro Focus COBOL to COBOL-IT by providing a Micro Focus command-line emulator. The user can rename cobmf to cob (or rename cobmf.exe to cob.exe in Windows environments) , and continue to use the same compiler flags and environment variables that they have developed over time. Establishing a link between cobmf and cob can also be useful:

>ln -s $COBOLITDIR/bin/cobmf $COBOLITDIR/bin/cob

Using citdb2.c

On some platforms, you may encounter a runtime error stating:

yourmodule.cbl:0: libcob: Cannot find module 'XXXXX'

Where XXXXX is a DB2 function called by your source.

To solve this you will need to add a 'fake' module to force the link of the function into your program. The COBOL-IT distribution includes the file $COBOLITDIR/lib/cobol-it/citdb2.c, which is intended to be used for this purpose. Citcb2.c includes a stub for the sqlgmf( ) function to serve as an example. You may expand this file to include stubs for all of the DB2 functions used in your COBOL program.

Including citdb2.c in a compile command is done as follows:

>cobc -x yourmod.cbl $COBOLITDIR/lib/cobol-it/citdb2.c

Source for citdb2.c

      /*
       * Copyright (C) 2008 Cobol-IT
       *
       * This program is free software; you can redistribute it and/or 
       *modify it under the terms of the GNU General Public License as 
       *published by the Free Software Foundation; either version 2, or 
       *(at your option) any later version.
       *
       * This program is distributed in the hope that it will be useful,
       * but WITHOUT ANY WARRANTY; without even the implied warranty of
       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
       * GNU General Public License for more details.
       *
       * You should have received a copy of the GNU General Public 
       * License along with this software; see the file COPYING. If not,
       * write to the Free Software Foundation, 51 Franklin Street, 
       * Fifth Floor Boston, MA 02110-1301 USA
       */

      /* This module is only a fake to use with DB2 Gmf library
       * to force a reference to the library.
       */
       extern void sqlgmf(void);

      /*
       * DO NEVER CALL this function... just link the module with your 
       * program using DB2gmf library
       */
       void CIT_db2_stub(void)
       {
              sqlgmf();
       }
Back to top