COBOL Manual for TNS and TNS/R Programs

Using HP COBOL in the OSS Environment
HP COBOL Manual for TNS and TNS/R Programs522555-006
19-6
Native Programs
Native Programs
Native HP COBOL programs can call programs written in native HP COBOL, native
HP C, native HP C++, or pTAL.
To produce a native HP COBOL program that contains native HP COBOL and native
HP C modules, follow these steps:
1. Using the c89 utility, compile the HP C modules, but do not link them.
2. Using the nmcobol utility, compile the HP COBOL modules, specifying any
necessary linking or SQL-compiling flags.
For example, suppose that you want to produce a loadfile from the native HP COBOL
modules cobol1.cbl and cobol2.cbl and the native HP C modules c1.c and
c2.c.
First you use the c89 utility to compile the HP C modules without linking them:
c89 -c -o cprog.o c1.c c2.c
The resulting object file is cprog.o.
Then you use the nmcobol utility to do this:
Compile the HP COBOL modules
Link the nmcobol compiler output, the object file cprog.o, and the native HP C
library.
Produce the loadfile myprog:
nmcobol -o myprog cprog.o cobol1.cbl cobol2.cbl
The nmcobol utility automatically links the HP C SRLs to myprog.
Changing Default Pathnames and Disk Volume
The “Default” column of Table 19-1 shows the default pathnames of the programs that
the cobol and nmcobol commands call and the default disk volume on which they
create temporary files.
To change one or more of these defaults before executing the cobol or nmcobol
command, use the export command.
To execute a cobol or nmcobol command with a specified set of environment
variables, use the OSS env function with the environment variables that Table 19-1
lists and explains. For the syntax of the env function, see the env(1) command
reference page either online or in the Open System Services System Calls Reference
Manual.
The effect of the export command lasts until you explicitly change it. The effect of the
env function applies only to the cobol or nmcobol command with which you use it.