[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
User Manual


Previous Contents Index

Technical Notes:

  1. If your program compile generates Errors (E-level diagnostics on OpenVMS), the link phase of the two steps taken by the compiler driver will be aborted and the object file(s) deleted. You can override this deletion by specifying the -c flag:


    % cobol -c test.cob
    % cobol test.o
    

    The HP COBOL compiler driver (see Section 1.1.2) controls a sequence of operations (as required): compiling, assembling, linking. The -c flag signals the compiler driver to break the sequence.
    (For additional information, see The COBOL Command Driver description (earlier in this chapter), Section 1.1.2.12, and the -c description under man cobol .)
  2. The -tps flag causes the HP COBOL compiler to use an external file handler (produced by a third party), providing increased flexibility in cross platform, transaction processing application development. See Section 1.1.2.3 for more information.
  3. Specifying the -xref_stdout option directs the compiler to output the data file to standard output.
  4. Any copy file that contains a PROGRAM-ID or END PROGRAM statement for a program must contain that entire program.

1.1.2.3 External File Handler Support

The -tps flag allows HP COBOL applications to make use of ACMSxp, the Application Control and Management System/Cross-Platform Edition.

-tps specifies that files are part of a transaction processing system, and enables Encina Structured File System (SFS) record storage for applicable files. It is intended to be used in conjunction with the Transarc Encina external file handler and ACMSxp, allowing access to data in a wide variety of databases, without the need to write code in the language of the databases. This approach provides access to transaction processing technology, and incorporates industry standards for data communications and distributed computing. ACMSxp conforms to the the Multivendor Integration Architecture (MIA).

COBOL is one of the languages approved by MIA for transaction processing (TP) client programs, customer-written presentation procedures, and processing procedures. For database access, Structured Query Language (SQL) is the MIA-required access language. The SQL is embedded in COBOL and C.

Refer to the ACMSxp documentation for full details. Additional information can also be found in published Distributed Computing Environment (DCE) documentation.

1.1.2.4 Specifying Multiple Files and Flags

The cobol command can specify multiple file names and multiple flags. Multiple file names are delimited by spaces. If appropriate, each file name can have a different suffix. The file name suffix could result in the following actions:

  • Calling another language compiler, such as the C compiler
  • Passing object files directly to the linker, which the linker combines with other object files
  • Passing an object library to the linker, which the linker uses to search for unresolved global references

When a file is not in your current working directory, specify the directory path before the file name.

1.1.2.5 Compiling Multiple Files

An entire set of source files can be compiled and linked together using a single cobol command:


% cobol -o calc mainprog.cob array_calc.cob calc_aver.cob

This cobol command:

  • Uses the -o flag to specify the name of the executable program as calc
  • Compiles the file array_calc.cob
  • Compiles the file calc_aver.cob
  • Compiles the file mainprog.cob , which contains the main program
  • Uses ld to link both the main program and object files into an executable program file named calc

The files can also be compiled separately, as follows:


% cobol -c array_calc.cob
% cobol -c calc_aver.cob
% cobol -o calc mainprog.cob array_calc.o calc_aver.o

In this case, the -c option prevents linking and retains the .o files. The first command creates the file array_calc.o . The second command creates the file calc_aver.o . The last command compiles the main program and links the object files into the executable program named calc .

If your path definition includes the directory containing calc , you can run the program by simply typing its name:


% calc

You can compile multiple source files by concatenating them:


% cat proga1.cob proga2.cob proga3.cob > com1.cob
% cat progb1.cob progb2.cob > com2.cob
% cobol -c com1.cob com2.cob

The resulting file names are com1.o and com2.o. The OpenVMS Alpha and I64 equivalent to this is:


$ COBOL proga1+proga2+proga3,progb1+progb2

1.1.2.6 Debugging a Program

To debug a program using the Ladebug Debugger, compile the source files with the -g flag to request additional symbol table information for source line debugging in the object and executable program files. The following cobol command also uses the -o flag to name the executable program file calc_debug :


% cobol -g -o calc_debug  mainprog.cob array_calc.cob calc_aver.cob

To debug an executable program named calc_debug, type the following command:


% ladebug calc_debug

For more information on running the program within the debugger, refer to the Ladebug Debugger Manual.

Pay attention to compiler messages. Informational and warning messages (as well as error-level messages) do not prevent the production of an object file, which you can link and execute. However, the messages sometimes point out otherwise undetected logic errors, and the structure of the program might not be what you intended.

1.1.2.7 Output Files: Object, Executable, Listing, and Temporary Files

The output produced by the cobol command includes:

  • An object file, if you specify the -c flag on the command line
  • An executable file, if you omit the -c flag
  • A listing file, if you specify the -V flag

If the environment variable TMPDIR is set, the value is used as the directory for temporary files.

You control the production of these files by specifying the appropriate flags on the cobol command line. Unless you specify the -c flag, the compiler generates a single temporary object file, whether you specify one source file or multiple source files separated by blanks. The ld linker is then invoked to link the object file into one executable image file.

The object file is in Tru64 UNIX extended coff format. The object file provides the following information:

  • The name of the entry point. It takes this name from the program name in the first PROGRAM-ID paragraph in the source program.
  • A list of variables that are declared in the module. The linker uses this information when it binds two or more modules together and must resolve references to the same names in the modules.
  • A symbol table and a source line correlation table (if you request them with the -g flag, for debugging). A symbol table is a list of the names of all external and internal variables within a module, with definitions of their locations. The source line correlation table associates lines in your source file with lines in your program. These tables are of use in debugging.

If severe errors are encountered during compilation or if you specify certain flags such as -c , linking does not occur.


Previous Next Contents Index