Compaq AAQ2G1FTK Marine Radio User Manual


 
Developing Compaq COBOL Programs
1.3 Developing Programs on OpenVMS Alpha
For more information about the OpenVMS Debugger, refer to Appendix C and the
OpenVMS Debugger Manual.
1.4 Program Run Messages
Incorrect or undesirable program results are usually caused by data errors or
program logic errors. You can resolve most of these errors by desk-checking your
program and by using a debugger.
1.4.1 Data Errors
Faulty or incorrectly defined data often produce incorrect results. Data errors can
sometimes be attributed to one or more of the following actions:
Incorrect picture size. As shown in the following sample of a partial program,
if the picture size of a receiving data item is too small, your data may be
truncated:
77 COUNTER PIC S9.
.
.
.
PROCEDURE DIVISION.
.
.
.
LOOP.
ADD 1 TO COUNTER
IF COUNTER < 10 GO TO LOOP.
The IF clause will produce an infinite loop because of the one-digit size limit
of COUNTER, which is PIC S9. If COUNTER were PIC S99, or if the clause
used 9 instead of 10, the condition could be false, causing a proper exit from
the loop.
Incorrect record field position. The record field positions that you specify in
your program may not agree with a file’s record field positions. For example,
a file could have this record description:
01 PAY-RECORD.
03 P-NUMBER PIC X(5).
03 P-WEEKLY-AMT PIC S9(5)V99 COMP-3.
03 P-MONTHLY-AMT PIC S9(5)V99 COMP-3.
03 P-YEARLY-AMT PIC S9(5)V99 COMP-3.
.
.
.
Incorrectly positioning these fields can produce faulty data.
In the following example, a program references the file incorrectly. The field
described as P-YEARLY-AMT actually contains P-MONTHLY-AMT data, and vice
versa.
1–52 Developing Compaq COBOL Programs