Configuring the Micro Focus COBOL compiler on Windows

When you develop an embedded SQL application with the Micro Focus COBOL compiler on Windows operating system, following db2 prep option and environment settings must be set.

Procedure

  • When you precompile your application using the PRECOMPILE command, use the target mfcob option.
  • Ensure that the LIB environment variable points to %DB2PATH%\lib by using the following command:
    set LIB="%DB2PATH%\lib;%LIB%"
  • The Db2® COPY files for Micro Focus COBOL reside in %DB2PATH%\include\cobol_mf. Set the COBCPY environment variable to include the directory as follows:
    set COBCPY="%DB2PATH%\include\cobol_mf;%COBCPY%"

    You must ensure that the previously mentioned environment variables are permanently set in the System settings. This can be checked by going through the following steps:

    1. Open the Control Panel
    2. Select System
    3. Select the Advanced tab
    4. Click Environment Variables
    5. Check the System variables list for the required environment variables. If not present, add them to the System variables list

    Setting them in either the User settings, at a command prompt, or in a script is insufficient.

What to do next

You must make calls to all Db2 application programming interfaces using calling convention 74. The Db2 COBOL precompiler automatically inserts a CALL-CONVENTION clause in a SPECIAL-NAMES paragraph. If the SPECIAL-NAMES paragraph does not exist, the Db2 COBOL precompiler creates it, as follows:

Identification Division
Program-ID. "static".
special-names.
    call-convention 74 is DB2API.

Also, the precompiler automatically places the symbol DB2API, which is used to identify the calling convention, after the "call" keyword whenever a Db2 API is called. This occurs, for example, whenever the precompiler generates a Db2 API runtime call from an embedded SQL statement.

If calls to Db2 APIs are made in an application which is not precompiled, you should manually create a SPECIAL-NAMES paragraph in the application, similar to that given previously. If you are calling a Db2 API directly, then you will need to manually add the DB2API symbol after the "call" keyword.