HP OpenVMS Systems Documentation

Content starts here

User Manual

Previous Contents Index Common Command-Line Errors to Avoid

The following are some common errors to avoid when entering COBOL command lines:

  • Omitting /ANSI_FORMAT for programs that are in ANSI format (AREA A, AREA B, and so forth)
  • Including contradictory options
  • Omitting a necessary qualifier, such as /LIST if you specify /MAP
  • Omitting version numbers from file specifications when you want to compile a program that is not the latest version of a source file
  • Forgetting to use a file suffix in the file specification, or not specifying /SOURCE when your source file suffix is not .COB or .CBL Compiling Programs with Conditional Compilation

To debug source code that contains conditional compilation lines, you can use either the /CONDITIONALS qualifier or the WITH DEBUGGING MODE clause. The /CONDITIONALS qualifier is listed in Table 1-4. For more information about the /CONDITIONALS qualifier, invoke the online help facility for HP COBOL at the system prompt. For more information about the WITH DEBUGGING MODE clause, refer to the HP COBOL Reference Manual.

Using the WITH DEBUGGING MODE clause as part of the SOURCE-COMPUTER paragraph causes the compiler to process all conditional compilation lines in your program as COBOL text. If you do not specify the WITH DEBUGGING MODE clause, and if the /CONDITIONALS qualifier is not in effect, all conditional compilation lines in your program are treated as comments.

The WITH DEBUGGING MODE clause applies to: (1) the program that specifies it, and (2) any contained program within a program that specifies the clause. Interpreting Messages from the Compiler

If there are errors in your source file when you compile your program, the HP COBOL compiler flags these errors and displays helpful messages. You can reference the message, locate the error, and, if necessary, correct the error in your program.

On Alpha and I64, the general format of compiler messages shown on your screen is as follows:

%COBOL-s-ident, message-text
At line number n in name <>

On VAX, the general format of compiler messages is as follows:

%COBOL-s-ERROR nnn, (m) message-text


The facility or program name of the HP COBOL compiler. This prefix indicates that the HP COBOL compiler issued the message.


The severity of the error, represented in the following way:
F Fatal error. The compiler does not produce an object module. You must correct the error before you can compile the program to produce an object module.
E Error. The compiler makes an assumption about what you intended and continues. However, the compiler's assumption may not relate to your intention. Correct the error.
W Warning. The compiler attempts to correct the error in the statement, but you should verify that the compiler's action is acceptable. Otherwise, your program may produce unexpected results.
I Informational. This message usually appears with other messages to inform you of specific actions taken by the compiler. No action is necessary on your part. Note that these messages are suppressed by default. You must invoke /WARN=ALL or /WARN=INFO to enable them.

ident (Alpha, I64)

The message identification. This is a descriptive abbreviation of the message text. <>

nnn (VAX)

The message identification number.

m (VAX)

The message pointer number. <>


The compiler's message. In many cases, it consists of no more than one line of output. A message generally provides you with enough information to determine the cause of the error so that you can correct it.

At line number n in name (Alpha, I64)

The integer n is the number of the line where the diagnostic occurs. The number is relative to the beginning of the file or text library module specified by name.

On Alpha and I64, a sample compiler message with two diagnostics looks like this in the listing file:

   12          PROCEDURE DIVISION.
   13          P-NAME
   14              MOVE ABC TO XYZ.
%COBOL-E-NODOT, Missing period is assumed

   14              MOVE ABC TO XYZ.
%COBOL-F-UNDEFSYM, Undefined name

In the sample, the first diagnostic pointer (^) points to the MOVE statement in source line number 14, which is the closest approximation to where the error (P-NAME is not followed by a period) occurred. The second diagnostic pointer points to XYZ, an undefined name in source line number 14. Each diagnostic pointer is followed by a message line that identifies, in this order:

  • The HP COBOL compiler generated the message
  • The severity code of the message
  • The message identification (a mnemonic of the message text)
  • The text of the message

Although most compiler messages are self-explanatory, some require additional explanation. The online help facility for HP COBOL contains a list and descriptions of these HP COBOL compiler messages. Use the HELP COBOL Compiler Messages command to access this list. <>

On OpenVMS VAX, diagnostic messages look like this example:

   12          PROCEDURE DIVISION.
   13          P-NAME
   14              MOVE ABC TO XYZ.
                   1           2
%COBOL-E-ERROR  65, (1) Missing period is assumed
%COBOL-F-ERROR 349, (2) Undefined name

Here, error pointer (1) points to the approximate place where the error occurred (P-NAME has no period). Error pointer (2) points to an undefined name in source line number 14. The two error pointers are followed by two error message lines that each identify, in this order:

  • That the COBOL compiler generated the error message
  • The severity code: Fatal (F), Error (E), Warning (W), or Informational (I)
  • The error message number
  • The error pointers
  • The error message <>

To examine messages that occurred during compilation, you can search for each occurrence of %COBOL in the compiler listing file. Section describes listing files. Using Compiler Listing Files

A compiler listing file provides information that can help you debug or document your HP COBOL program. It consists of the following sections:

  • Program listing
    The program listing section contains the source code plus line numbers generated by the compiler. Any diagnostics will appear in this section.
  • Storage map
    The storage map section is optional (produced by the /MAP qualifier); it contains summary information on program sections, variables, and arrays.
  • Compilation summary
    The compilation summary section lists the qualifiers used with the COBOL command and the compilation statistics.
  • Machine code
    The machine code section is optional; it displays compiler-generated object code.

To generate a listing file, specify the /LIST qualifier when you compile your HP COBOL program interactively as in the following example for PROG_1.COB:


If you compile your program as a batch job, the compiler creates a listing file by default. You can specify the /NOLIST qualifier to suppress creation of the listing file, if that suits your purposes. (In either case, however, the listing file is not automatically printed.) By default, the name of the listing file is the name of your source file followed by the file type .LIS. You can include a file specification with the /LIST qualifier to override this default.

When used with the /LIST qualifier, the following COBOL command qualifiers supply additional information in the compiler listing file:

  • /COPY_LIST---Includes source statements specified by the COPY command.
  • /CROSS_REFERENCE---Creates a cross-reference listing of user-defined names and references.
  • /MACHINE_CODE---Includes a list of compiler-generated machine code.
  • /MAP---Produces maps, data names, procedure names, file names, and external references.

For a description of each qualifier's function, invoke the online help facility for COBOL at the system prompt as follows:


Compiler Listing File for a Contained Program

A contained COBOL program listing file includes two additional program elements that provide nesting level information about the main program and the contained program. For additional information about contained programs, see Chapter 12, Interprogram Communication.

Previous Next Contents Index