Debugging a client application and Db2 stored procedure
The following instructions pertain to a specialized technique that allows for the debugging of a client application (i.e., a Db2 batch program) which calls a Db2 stored procedure, while using a single TSO userid.
Note the following instructions:
Access the Code Debug TSO Process Execute JCL screen (following figure) by entering a Y in the User Supplied WLM JCL field of Code Debug TSO Process DB2 Stored Procedures Screen.
Code Debug TSO Process Execute JCL Screen
--------------------------- PROCESS EXECUTE JCL -----------------------
COMMAND ===>
Primary Commands: blank (Process JCL) Browse Edit SEtup STatus
ISPF Library:
Project ===> PFHABC0
Group ===> BATCON ===> ===> ===>
Type ===> JCL
Member ===> (Blank for member selection list)
Other Partitioned or Sequential Dataset:
Dataset Name ===> 'CPWR.XT.SLXTSAMP'
Volume Serial ===> (If not cataloged)
Press ENTER to process or enter END command to terminateType the name of your pre-defined data set in the Data set Name field of the Process Execute JCL screen and press Enter to access the Second Process Execute JCL screen(following figure). If you wish to have a data set name provided for this example, use the data set name of the Code Debug TSO SAMPLIB. The default name is:
‘CPWR.XT.SLXTSAMP’Second Process Execute JCL Screen
--------------------------- PROCESS EXECUTE JCL ---------- ROW 00031 OF 00043
COMMAND ===> SCROLL ===> PAGE
Line Commands: B (Browse) E (Edit) S (Select for processing)
Dataset: 'CPWR.XT.SLXTSAMP'
Name Prompt Size Created Changed ID
-------------------------------------------------------------------------------
_ JCL015 102 2000/10/17 2000/10/17 12:29:17 PFHABC0
_ JCL015O 96 2000/10/17 2000/10/17 10:17:51 PFHABC0
_ LISTPROC 6 2000/10/24 2000/10/26 09:47:46 PFHABC1
_ LISTPRO5 6 2000/10/24 2000/10/24 13:17:49 PFHABC0
_ TRIJCLSM 42 2000/10/24 2000/10/24 12:00:38 PFHABC1
S TRIJCLST 46 2000/10/24 2000/10/24 11:55:50 PFHABC1
_ TRISPMB 47 2000/10/23 2000/10/23 11:47:21 PFHABC0
_ TRISPT6 34 2000/10/23 2000/10/23 11:27:22 PFHABC0
_ UNLOAD1 28 2000/10/16 2000/10/17 09:18:34 PFHABC0
_ XTUNLD 60 2000/10/17 2000/10/17 09:33:51 PFHABC0
_ XTUNLDO 53 2000/10/17 2000/10/17 09:25:44 PFHABC0
_ XTUPDATE 484 2000/10/17 2000/10/17 09:25:37 PFHABC0
_ X70CW40 435 2000/10/17 2000/10/17 12:45:35 PFHABC0
**End**Scroll down (PF8) to the member name which has been defined for the stored procedure. For the continuity of this example, the member name is TRIJCLST. Type an S in the field to the left of TRIJCLST and press Enter. If you do not receive any error messages, you should have returned to the Select Job Step screen (similar to following , Select Job Step screen # 3).
The Data set field should now include the member name (TRIJCLST) enclosed in parentheses.
Type SUBmit on the Command line of the Code Debug TSO Select Job Step screen # 3 (as shown in following figure). Type an I in the field immediately to the left of the PROGRAM field of the Select Job Step screen # 3. Press Enter to submit the Db2 stored procedure. You should receive an online message at the bottom of your screen stating that your job was submitted.
Code Debug TSO Select Job Step Screen # 3
PROFILE: DB2SP------------------- SELECT JOB STEP --------------- Row 1 of 1
COMMAND ===> SUB SCROLL ===> PAGE
Line Commands: Primary Commands:
I - Interactive testing Edit - Display converted selected steps
U - Unattended testing END - Exit without processing
Followed optionally by: RUN - Submit and connect
C - Code Coverage SEtup - Setup work datasets
T - Code Coverage, plus TDO SUBmit - Convert selected steps and submit
F - System Flow (F, CF or TF) STatus - Display status of submitted job(s)
Dataset: 'CPWR.XT.SLXTSAMP(TRIJCLST)'
PROGRAM INITSCR POSTSCR STEPNAME PROCNAME PROCSTEP EXEC PGM
----------------------------------- -----------------------------------------
I___ DSNX9WLM ________ ________ ________ SERVER IEFPROC
******************************* Bottom of data ********************************Press Enter and you will view a four line message similar to the message displayed in following figure. If you do not receive the WAITING FOR CONNECTION message, you will view a message on your screen stating:
JCL HAS BEEN MODIFIED TO DEBUG WITH XPEDITERStored Procedure Waiting for Connection Message
+XPD0011 VTAM NODE: A01CS000 USER: PFHABC0 JOBNAME: PFHABC0S
+XPD0012 JOBNUMBER: JOB12001 STEP: IEFPROC PROCSTEP:
+XPD0013 IS WAITING FOR CONNECTION ON SYSTEM CW01.
***- Press Enter to remove the messages from your screen. You should remain in the Select Job Step screen # 3.
Type STatus on the Command line of the Select Job Step screen # 3 and press Enter to access the Code Debug TSO Status screen #1(following figure).
Code Debug TSO Status Screen # 1 (Stored Procedure)
------------------------------------- STATUS --------------------------------
COMMAND ===> SCROLL ===> PAGE
Line Commands: A (Attach) B (Browse) C (Cancel) USERID => PFHABC0
I (Info) P (Purge) R (Requeue)
Jobname ===> (Specific jobname, blank for TSO userid, or
'*' for all jobs using batch connect)
Sort Sequence ===> JOBID (JOBNAME/JOBID)
CMD JOBNAME JOBID STATUS H CONNECT MESSAGE
-------------------------------------------------------------------------------
__ PFHABC0S JOB12006 Running N Ready
******************************* Bottom of data ********************************Type an asterisk (*) in the Jobname field of above figure and press Enter to refresh the Status screen and view the status of the stored procedure job. A single line of data is displayed on Status screen # 1. This line displays the stored procedure Jobname in the JOBNAME field and a valid JOBID number. The CONNECT field should indicate that the stored procedure is ready to connect.
- Using Code Debug Batch Connect (which is OPTION 3 (BATCH) on the Code Debug TSO Primary Menu), set up the client application that has been selected to call the stored procedure. It will duplicate steps 1 through 7.
Type an asterisk (*) in the Jobname field of the Code Debug TSO Status screen # 2 (following figure) and press Enter to refresh the Status screen and view the status of both the client application job and the stored procedure.
Code Debug TSO Status Screen # 2 (Client Application and Stored Procedure)
-------------------------------------- STATUS -------------------- Row 1 of 2
COMMAND ===> SCROLL ===> CSR
Line Commands: A (Attach) B (Browse) C (Cancel) USERID => PFHABC0
I (Info) P (Purge) R (Requeue)
Jobname ===> (Specific jobname, blank for TSO userid, or
'*' for all jobs using batch connect)
Sort Sequence ===> JOBNAME (JOBNAME/JOBID)
CMD JOBNAME JOBID STATUS H CONNECT MESSAGE
-------------------------------------------------------------------------------
__ PFHABC0C JOB12006 Running Ready
__ PFHABC0S JOB12001 Running Ready
******************************* Bottom of data ********************************A new line of data is now displayed containing both a valid jobname (your client jobname in the JOBNAME field) and a valid jobID number. The CONNECT field should indicate that both the client job and the stored procedure are ready to connect. After you have verified that your client job is ready to connect, type an A next to the client application jobname in the CMD field of the Code Debug TSO Status screen # 3 (following figure). Press Enter to connect to the client application job.
Code Debug TSO Status Screen # 3 (Client Application and Stored Procedure)
--------------------------------------- STATUS ------------------- Row 1 of 2
COMMAND ===> SCROLL ===> CSR
Line Commands: A (Attach) B (Browse) C (Cancel) USERID => PFHABC0
I (Info) P (Purge) R (Requeue)
Jobname ===> (Specific jobname, blank for TSO userid, or
'*' for all jobs using batch connect)
Sort Sequence ===> JOBNAME (JOBNAME/JOBID)
CMD JOBNAME JOBID STATUS H CONNECT MESSAGE
-------------------------------------------------------------------------------
A PFHABC0C JOB12006 Running Ready
__ PFHABC0S JOB12001 Running Ready
******************************* Bottom of data ********************************The source for the client application should appear on the Code Debug TSO Source screen # 1 (following figure). Enter a before breakpoint on the line where the stored procedure is called.
Code Debug TSO Source Screen # 1 (Client Application)
----------------------------- CODE DEBUG TSO - SOURCE -----------------------
COMMAND ===> SCROLL ===> CSR
BEFORE BREAKPOINT ENCOUNTERED
----+----1----+----2----+----3
MORE-> 01 SQL-PLIST1 > ......TRISPM ..B...~0.....Q..
** END **
------ --------------------------------------- Before TRISPM:182/AMODE 31 <>
000181 PERFORM SQL-INITIAL UNTIL SQL-INIT-DONE
=====> B CALL 'DSNHLI' USING SQL-PLIST1.
000183 IF SQLCODE IS LESS THAN ZERO
000184 MOVE SQLCODE TO ERROR-SQLCODE
000185 MOVE 'CALL' TO ERROR-TABLE
000186 PERFORM SQL-ERROR
000187 A GOBACK.
000188 SET TX TO TRIANGLE-TYPE.
000189 ADD 1 TO N-CNTR (TX).
000190 *
000191 ENDING-PARA.
000192 CLOSE INFILE.
000193 CALL 'TRIRPT' USING NAME-N-CNTR-TABLE.
000194 *- Enter any desired Code Debug TSO testing commands that you require.
- When the before breakpoint on the stored procedure call is encountered, type GO 1 on the Command line and press Enter.
Immediately following issuance of the GO 1 command, the client application will “lock” (control having been transferred to the stored procedure). Press the Attention key twice. The screen that is displayed contains the following two lines:
XPED
ENTER ATTENTION OPTION OR HELP FOR LIST OF OPTIONS- Type DISC (to disconnect) on the line after the message displayed on the screen, and press Enter. This will return you the Status screen without terminating the client application test.
Type an A (next to the stored procedure JOBNAME) in the CMD field of the Code Debug TSO Status screen # 4 (following figure) and press Enter. This will connect you to the stored procedure.
Code Debug TSO Status Screen # 4 (Client Application and Stored Procedure)
-------------------------------------- STATUS -------------------- Row 1 of 2
COMMAND ===> SCROLL ===> CSR
Line Commands: A (Attach) B (Browse) C (Cancel) USERID => PFHABC0
I (Info) P (Purge) R (Requeue)
Jobname ===> * (Specific jobname, blank for TSO userid, or
'*' for all jobs using batch connect)
Sort Sequence ===> JOBNAME (JOBNAME/JOBID)
CMD JOBNAME JOBID STATUS H CONNECT MESSAGE
-------------------------------------------------------------------------------
__ PFHABC0C JOB12006 Running Ready
A PFHABC0S JOB12001 Running Ready
******************************* Bottom of data ********************************The source for the stored procedure should appear on the Code Debug TSO Source screen # 2 (following figure).
Code Debug TSO Source Screen # 2 (Stored Procedure)
------------------------------ CODE DEBUG TSO - SOURCE -----------------------
COMMAND ===> SCROLL ===> CSR
BEFORE BREAKPOINT ENCOUNTERED
---
000010 01 TST-REC > 345
000014 01 TYPE-OF-TRIANGLE > ?? INVALID DECIMAL
** END **
------ ------------------------------------------- Before TRISPT/AMODE 31 <>
=====> B PROCEDURE DIVISION USING TST-REC
000016 TYPE-OF-TRIANGLE
000017 VALIDATE-TRIANGLE
000018 ADD A B GIVING A-N-B.
000019 ADD A C GIVING A-N-C.
000020 ADD B C GIVING B-N-C.
000021 IF (B-N-C NOT > A) OR (A-N-C NOT > B) OR (A-N-B NOT > C)
000022 MOVE 4 TO TYPE-OF-TRIANGLE.
000023 DETERMINE-TYPE.
000024 IF TYPE-OF-TRIANGLE = 4
000025 NEXT SENTENCE
000026 ELSE
000027 IF (A = B) AND (B = C)
000028 MOVE 1 TO TYPE-OF-TRIANGLE- Enter any desired Code Debug TSO testing commands that you require.
To return to the Client application, type GO at the end of the stored procedure and press Enter. If you had specified the number 1 in the Maximum number of Tests field when setting up the stored procedure for debugging with Code Debug TSO, you will now be placed in the session log data set with a TEST COMPLETED message. Entering GO will cleanly end the stored procedure test. If you had specified a number greater than 1 in the Maximum number of Tests field when setting up the stored procedure for debugging with Code Debug TSO, the stored procedure will “lock” (control having been returned to the client application). Press the Attention key twice. The screen that is displayed contains the following two lines:
XPED
ENTER ATTENTION OPTION OR HELP FOR LIST OF OPTIONS- Type DISC (to disconnect) on the line after the message displayed on the screen, and press Enter. This will return you the Status screen without terminating the stored procedure environment.
- Type an A (next to the client application JOBNAME) in the CMD field of the Code Debug TSO Status screen # 3 and press Enter. This will connect you to the client application.
You should now be able to view the Code Debug TSO Source screen # 3 (following figure) that displays the client application, just after the stored procedure call.
Code Debug TSO Source Screen # 3 (Client Application)
------------------------------ CODE DEBUG TSO - SOURCE -----------------------
COMMAND ===> SCROLL ===> CSR
PROGRAM: TRISPM MODULE: TRISPM COMP DATE: 10/23/2000 COMP TIME:11:52:35
COBOL K TX > 1 INDEX
000059 05 SQLCODE > +000000000 FULLWORD
** END **
------ --------------------------------------- Before TRISPM:183/AMODE 31 <>
000181 PERFORM SQL-INITIAL UNTIL SQL-INIT-DONE
000182 B CALL 'DSNHLI' USING SQL-PLIST1.
=====> IF SQLCODE IS LESS THAN ZERO
000184 MOVE SQLCODE TO ERROR-SQLCODE
000185 MOVE 'CALL' TO ERROR-TABLE
000186 PERFORM SQL-ERROR
000187 A GOBACK.
000188 SET TX TO TRIANGLE-TYPE.
000189 ADD 1 TO N-CNTR (TX).
000190 *
000191 ENDING-PARA.
000192 CLOSE INFILE.
000193 CALL 'TRIRPT' USING NAME-N-CNTR-TABLE.
000194 *- Continue repeating steps 15 through 23 to switch back and forth between the stored procedure and the client application. For the stored procedure, when the maximum number of tests (specified when you first set up the stored procedure test) has been reached, you will be positioned in the Code DebugLog Data set screen with the message TEST COMPLETED. When this message appears, type GO on the command line and press Enter to exit the stored procedure.
Because you entered GO 1 in Step 15, you must now reattach to the client application and allow it to run to completion. This is normally done by entering the GO command.