Skip to content

Guidelines for Use of -preprocess=cmd

The -preprocess=cmd compiler flag implements the COBOL-IT integrated pre-processor. Preprocessors (like Oracle procob) may now be called by the compiler after the COBOL preprocessing of COPY/REPLACING clauses has been completed. Usage of the -preprocess compiler flag allows for use of the -fdebug-exec compiler flag, which permits the user to run the original source code (before precompiling) in the debugger.

Note

When using -preprocess=cmd the COBOL-IT Preprocessor ignores INCLUDE statements, as these must must be processed by the external preprocessor.

Usage:

-preprocess=cmd [filename]

[filename] is a COBOL source file that needs to be precompiled before being compiled by the COBOL-IT COBOL compiler. A common case is a COBOL program containing ESQL statements, allowing it to interact with an Oracle® database. Such a program would need to be precompiled by the Oracle® precompiler procob.

cmd is the external preprocessor command that take 2 parameters:

  • The first parameter is the input file name.
  • The second parameter is the output file name.

Consider the sample script, citprocob.sh, provided in the Linux/Unix distributions:

citprocob.sh

In Linux/Unix distributions, a sample script called citprocob.sh is located in $COBOLITDIR/bin/, which executes the command:

procob format=TERMINAL iname=$1 oname=$2.

With this script, you can execute the command:

cobc -preprocess=citprocob.sh testsql.pco

to cause the Oracle precompiler to run, and preprocess a pco file, producing an intermediate output file.

Note that while the command file takes two parameters, only one parameter is supplied to the -preprocess compiler flag. The second parameter is provided by the compiler cobc, as it generates a target file, and supplies it with a name.

Example:

In Linux/Unix:

       >cobc -conf=oraconf.conf -x -preprocess=citprocob.sh
       procobdemo.pco $ORACLE_HOME/precomp/lib/cob sqlintf.o -L
       $O RACLE_HOME/lib/ -l clntsh

where citprocob.sh contains the line:

procob format=TERMINAL iname=$1 oname=$2

In Windows:

       >cob -conf=myconf.conf -b -preprocess=cobcmake1
       procobdemo.pco -L %ICLIBHOME% -l %SQLLIB_lib%

where the following runtime environment variables are set:

  • set ICHOME=C:\COBOL\INSTANTCLIENT_11_2 set
  • ICLIBHOME=%ICHOME%\sdk\lib\msvc set
  • PCBCFG=%ICHOME%\precomp\admin\pcbcfg.cfg set
  • PROCOB=%ICHOME%\sdk\procob.exe set SQLLIB_lib=orasql11.lib

and where cobcmake1.bat contains the line:

%PROCOB% config=%PCBCFG% ireclen=132 iname=%1 oname=%2

Special cases:

To allow the compiled object to be run in the debugger, add the -g compiler flag, Note that the use of -preprocess provides debugging of original source code, and precompiled code is not displayed in the debugger.

       cobc -g -conf=myconf.conf -b -preprocess=cobcmake1
       procobdemo.pco -L %ICLIBHOME% -l %SQLLIB_lib%

If you prefer debugging original source code, while maintaining the ability to trace generated source code, add the -fdebug-exec compiler flag:

       cobc -g -fdebug-exec -conf=myconf.conf -b
       -preprocess=cobcmake1 procobdemo.pco -L %ICLIBHOME% -l %SQLLIB_lib%
Back to top