Halting on a COBOL line only if a condition is true
Often a particular part of your program works fine for the first
few thousand times, but it fails under certain conditions. You don't
want to just set a line breakpoint because you will have to keep entering GO
.
Example: sample COBOL program for debugging
For example, in COBVALU you want to stop at the calculation
of present value only if the discount rate is less than or equal to
-1 (before the exception occurs). First run COBCALC, step
into COBVALU, and stop at the statement labeled VALU1 .
To accomplish this, issue these z/OS® Debugger commands
at the start of COBCALC:
AT 67 ; GO ;
CLEAR AT 67 ; STEP 4 ;
Now set the breakpoint like this:
AT 44 IF INTEREST > -1 THEN GO ; END-IF ;
Line 44 is the statement labeled VALU3 .
The command causes z/OS Debugger to stop
at line 44. If the value of INTEREST is greater than -1, the program
continues. The command causes z/OS Debugger to remain
on line 44 only if the value of INTEREST is less than or equal to
-1.To force the discount rate to be negative, enter the z/OS Debugger command:
MOVE '-2 5' TO INPUT-1 ;
Run the program
by issuing the GO
command. z/OS Debugger halts
the program at line 44. Display the contents of INTEREST by issuing
the LIST INTEREST
command. To view the effect of
this breakpoint when the discount rate is positive, begin a new debug
session and repeat the z/OS Debugger commands
shown in this section. However, do not issue the MOVE '-2
5' TO INPUT-1
command. The program execution does not stop
at line 44 and the program runs to completion.