Tracing program logic
Trace the logic of your program by adding
For example, if you determine that the problem is in
EVALUATE statement or in a set of nested
DISPLAY statements in each path to see the logic
flow. If you determine that the calculation of a numeric value is
causing the problem, use
DISPLAY statements to check
the value of some interim results.
If you use explicit scope terminators to end statements in your program, the logic is more apparent and therefore easier to trace.
To determine whether a particular routine started and finished, you might insert code like this into your program:
DISPLAY "ENTER CHECK PROCEDURE"
. (checking procedure routine)
DISPLAY "FINISHED CHECK PROCEDURE"
After you are sure that the routine works correctly,
DISPLAY statements in one of two ways:
- Put an asterisk in column 7 of each
DISPLAYstatement line to convert it to a comment line.
- Put a
Din column 7 of each
DISPLAYstatement to convert it to a comment line. When you want to reactivate these statements, include a
WITH DEBUGGING MODEclause in the
ENVIRONMENT DIVISION; the
Din column 7 is ignored and the
DISPLAYstatements are implemented.
Before you put the program into production, delete or disable the debugging aids you used and recompile the program. The program will run more efficiently and use less storage.
DISPLAY statement (Enterprise COBOL for z/OS® Language Reference)