514 Using IBM Application Development Tools for z/OS and OS/390
5. Issue the RFIND command until you locate the record that has a value of IBM in the
In Figure 28-7 on page 513, you can see that the value in the NO_SHARES column is -5.
This is incorrect data in the application. No negative value allowed.
At this point, you believe the problem is due to faulty logic in the program that updates the
You can review the compiler listing to get an overview of the program, and to see where the
table is processed.
You decide to debug the program with Debug Tool.
28.2.3 Using Debug Tool to identify the logic problem
Set up the debug session for the TDB2 transaction in your CICS region:
1. Enter transaction ID DTCN to update your profile, as shown in Figure 28-8.
Figure 28-8 Debug Tool CICS transactions control profile
2. Enter the program name MYTRADMD in the Program ID field, and press Enter.
3. Press PF4 to save the profile.
4. Repeat these two steps for program MYTRADD.
5. PF3 to exit from this panel.
Tip: If your site allows only one entry, monitor the TDB2 transaction or just the terminal
ID to achieve the same results. The best is to monitor the terminal.
Note: We used a preference file to select correct colors within the Debug Tool session
Chapter 28. Scenario 3: Is the error in DB2 data or program logic? 515
6. Enter the transaction ID TDB2.
The debug session is started, as shown in Figure 28-9.
Figure 28-9 Debug session starting for program MYTRADMD
7. Issue the following commands on the command line to stop the program’s execution when
the program MYTRADD is invoked:
AT APPEARANCE MYTRADD
AT ENTRY MYTRADMD::>MYTRAD;
8. Press PF9 to run the program.
9. Press PF9 repeatedly and enter the appropriate values until the Shares - Buy screen is
10.In the Shares - Buy screen, enter 5 in the Number of Shares to Buy field, and press Enter.
11.Press PF9 to continue program execution.
The program stops when the program MYTRADD is invoked.
12.Issue the following command to monitor the value of the NO-SHARES field (the host variable
for the column NO_SHARES in the CUSTOMER_DETAILS table):
MONITOR LIST NO-SHARES;
Note: You can also use the one line syntax:
AT APPEARANCE MYTRADD perform AT ENTRY MYTRADMD::>MYTRAD; end-perform;
Tip: Two other variables are interesting and may also be monitored:
MONITOR LIST NO-OF-SHARES-DEC
MONITOR LIST %HEX (SHARES-OVERFLOW)
This last one must keep a value of X’00’.
516 Using IBM Application Development Tools for z/OS and OS/390
The value of these variables is displayed in the Monitor window, as shown in Figure 28-10.
Figure 28-10 Monitoring the value in NO-SHARES
13.Press PF2 to step through the program one line at a time. As you do, keep monitoring the
value of NO-SHARES in the Monitor window.
You see that the value in NO-SHARES is -5, as shown in Figure 28-11, after the record in the
CUSTOMER_DETAILS table is read in the READ-CUSTOMER-TABLE paragraph.
Figure 28-11 Monitoring the value in NO-SHARES after table read
14.Press PF2 to check the program flow before the program updates the Customer table.
The number of shares to be bought is added to the existing value in NO-SHARES in the
CALCULATE-SHARES-BOUGHT paragraph. This is done before the table is updated in the
Chapter 28. Scenario 3: Is the error in DB2 data or program logic? 517
The value of NO-SHARES is now 0, as shown in Figure 28-12.
Figure 28-12 Monitoring the value in NO-SHARES now in error
Conclusion 1: The buy process actually zeros the value; therefore, the display shows
zero number of shares.
You continue the debugging session to review the Sell processing portion of the program.
The Options panel is displayed.
16.Select option 3 and press Enter.
17.Enter 5 in the Number of Shares to Sell field.
18.Press PF2 to step through the program one line at a time. You continue to watch the value
of NO-SHARES in the Monitor window.
You can see that the value of NO-SHARES after the READ-CUSTOMER-TABLE paragraph is
executed is 0, as shown in Figure 28-13.