Handling run-time errors of COBOL
Code Debug TSO intercepts program abends and prevents the system from producing a dump.
When an abend occurs in a program for which the source is available, execution automatically pauses, the execution arrow points to the offending statement, and a message indicating the action to take is displayed.
The following figure is an example of Code Debug TSO responding to an abend.
Code Debug TSO Responding to a S0C7 Abend
COMMAND ===> SCROLL ===> CSR
S0C7 ABEND ENCOUNTERED, USE "AA SNAP" COMMAND FOR ADDITIONAL INFORMATION
000011 05 A > ?? INVALID DECIMAL
000012 05 B > ?? INVALID DECIMAL
000006 01 A-N-B > ???? INVALID DECIMAL
** END **
------ --------------------------------- SOC7 Abend at TRITST:18/AMODE 24 <>
000015 B PROCEDURE DIVISION USING TST-REC
000016 TYPE-OF-TRIANGLE.
000017 VALIDATE-TRIANGLE.
=====> 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.
To assist you in determining the cause of the abend and how to correct the problem, Code Debug TSO provides the following:
If Abend-AID Release 7.0.2 or above is installed at your site, you can enter AA SNAP to display an Abend-AID Snapshot report.
- Use the LOG command to display the diagnostic summary contained in the session log.
- Use the HELP command to display help information about the abend.
- Use debugging commands to investigate the cause of the abend.
Displaying the Abend-AID Snapshot Report
When an abend occurs in your program during a Code Debug TSO test session and Abend-AID is installed at your site, you can display an Abend-AID Snapshot report. This report contains context sensitive diagnostic information. (The report will not contain source support.)
In a non-abending situation, you can request the Snapshot report to display environment specific run-time characteristics and subsystem-related debugging information for VSAM, IDMS, IMS, and Db2 (if you have these Abend-AID options). See Displaying Environmental Data for more information.
To display the Snapshot report, enter AA SNAP on the command line of any run-time screen. The Snapshot report is formatted according to your terminal size (80 or 133) and written to a temporary data set DD called ABENDAID.
The following figure shows the header page of the Snapshot report:
Abend-AID Snapshot Report Header
| COMMAND ===> SCROLL ===> C
| PROGRAM: TRITST MODULE: TRIMAIN COMP DATE: 08/23/95 COMP TIME: 18:05
| ---------------------------------------------------S0C7 Abend at TRITST:18
| SYS95054.T181542.RA000.FLGDAA1.R0134656 dd ABENDAID line 00
| ********************************* TOP OF DATA ******************************
|1 A B E N D - A I D PAGE 1
|
| MONDAY 03 APR 2023 H17.02.00 R17.02.00
| ***********************************************************************
| * A b e n d - A I D D i a g n o s t i c s *
| ***********************************************************************
| Copyright (C) 1976, 2023, BMC Corporation. Unpublished.
| Rights Reserved Under The Copyright Laws Of The United States.
|
| Licensed for use at: XXXXXX
| YOUR COMPANY NAME
|
| Online Technical Support available at: https://support.bmc.com
|
| JESID - T0883121 OPSYS - z/OS 2.4.0 Model - 8562
| Job - FLGDAA1 DFSMS/MVS - V2R4M0 CP FMID - HBB77C0
| Step - TSOPROC JES2 - z/OS 2.4 System - LPAR
| Time - 09.02.27
+-----------------------------------------------------------------------------
Optionally, you can display a column template at the top of the report by using SET COLS ON. The column template can be useful when viewing records or data. Enter SET COLS OFF (the default) to turn off the column template.
Browsing the Snapshot Report
The Snapshot report can be browsed using the PF8 (DOWN) and PF7 (UP) keys. You can also bypass the header page and go directly to a specific section of the Snapshot report from the source display. For example, to go directly to the Diagnostic Section, you can enter the following:
AA SNAP; FIND ’DIAGNOSTIC’The Diagnostic Section of the report is displayed, as shown in the following figure.
Snapshot Report Diagnostic Section
COMMAND ===> SCROLL ===> CSR
CHARS 'DIAGNOSTIC' FOUND
------------------------------------------ SOC7 Abend at TRITST:18/AMODE 24 ->
SYS95054.T181542.RA000.FLGDAA1.R0134656 dd ABENDAID line 00000
**********************
* Diagnostic Section *
**********************
Both fields are in error
* First field in error *
The data causing the error is located in a temporary work field. The
external decimal field cannot be located.
* Second field in error *
A Data Exception was caused by data referenced at displacement 001
from the start of BLL cell 03. The field contains X'CD'. Refer to
the data division map in the program listing to locate the field name.
The second field causing the exception is located in a temporary work
field in the TGT. The actual field in error is in the linkage section
of program TRITST.
When you have finished viewing the Snapshot report, press PF3 (END) to return to the source display.
If you inadvertently press PF3 (END) while viewing the Snapshot report, you can enter BROWSE ABENDAID on the command line of the source or session log display to redisplay the Snapshot report.
Viewing the Session Log
Code Debug TSO records the cause of the abend, the exact location, and a diagnostic summary in the session log. To look at the session log, enter LOG on the command line of the Source display screen.
Diagnostic Summary in the Session Log
COMMAND ===> SCROLL ===> CSR
PROGRAM: TRITST MODULE: TRIMAIN COMP DATE: 08/23/1995 COMP TIME: 18:05:01
------------------------------------------- SOC7 Abend at TRITST:18/AMODE 24 --
GO
XPD0439 RA105 SOC7 ABEND AT 0014DDE8 REASON CODE 00000007
PSW AT TIME OF ERROR 078D0000 - 0014DDEE
DATA AT PSW - FA10D20E D217F321 7000D20E
GP REGISTERS AT ABEND 0 00000000 1 5014DFD4 2 0014B0C4 3 800C968
4 0014B400 5 8014B078 6 0014B080 7 0014DB5
8 8014B078 9 0014DF8E 10 0014DAB0 11 0014DDB
12 0014DD98 13 0014DB68 14 0014DDB8 15 4014DF9
INTERRUPT ADDRESS AT OFFSET 002E80 IN LOAD MODULE TRIMAIN
*** SOC7 ABEND IN USER MODULE TRITST AT STATE 000018 AT OFFSET 00032C
IN PROC VALIDATE-TRIANGLE VERB ADD
*** ACTIVE APPLICATION MODULE AT TIME OF ABNORMAL TERMINATION IS TRITST ***
*** APPLICATION MODULE CONTROL HIERARCHY AT TIME OF ABNORMAL TERMINATION ***
LVL MODULE ENTRY MEMBER RETURN LOCATION FOR MOST RECENT CALL
1 CODEDEBG
2 TRIMAIN TRIMAIN TRIMAIN STATE 000051 ANALYZE-NEXT-REC
3 X TRITST TRITST TRIMAIN
DATA EXCEPTION INTERRUPT INSTRUCTION AND OPERANDS
MNEMONIC ZAP INSTRUCTION FA10D20ED217 OP1 00BA
OP2 DC
The first part of the diagnostic summary identifies the error message, PSW, data at PSW, general-purpose registers, offset, and the module in which the error occurred.
The middle part shows the abend type, module name, statement number, offset, paragraph name, and the failing verb. This information is followed by the module stack that identifies the last call that took place.
The last part defines the problem and gives the next sequential instruction to be executed in the Assembler format.
If desired, the load modules can also be displayed by entering SHOW MODULES.
Displaying HELP Information
The HELP command can be used to obtain further information to determine the cause and possible resolution of the abend. Any of the most commonly occurring abends (listed as follows) can be entered as a keyword with the HELP command.
SB37 S0C4 S001 S106
SD37 S0C5 S013 S213
The following figure shows HELP information for a S0C7 abend.
HELP Information on S0C7
COMMAND ===> SCROLL ===> CSR
PROGRAM: TRITST MODULE: TRIMAIN COMP DATE: 06/18/1997 COMP TIME: 18:05:01
------------------------------------------- SOC7 Abend at TRITST:18/AMODE 31 ->
********************************** TOP OF DATA ********************************
S0C7
Data in a field was of incorrect format for the instruction attempting to
process it.
POSSIBLE CAUSES
1. A data-element was not initialized.
2. JCL error resulted in the wrong file being read into the program.
3. MOVE at group level was executed to a COMP or COMP-3 field. No data
conversion was performed on the element level.
4. The Linkage Section data item was improperly defined.
WHAT TO DO
1. PEEK data-elements in abending statement and MOVE valid data to the file
Analyzing the Problem
When an abend occurs, you can use Code Debug TSO debugging commands to investigate the cause of the abend. For example, you can view the contents of the data referenced on the statement causing the abend, analyze the data flow and control structure, and optionally, review the path and data values that lead to the error.
Applying Fixes
Even when Code Debug TSO intercepts an abend, you have the opportunity to temporarily apply fixes to the problem and resume execution as if the abend had never occurred. The GO (PF12) command resumes execution. However, there may be times that you will not be able to continue normal program execution until the abend is resolved.
Using all of the information provided by the Abend-AID Snapshot report, you can experiment with possible solutions and test the fixes.
Obtaining a Memory Dump
If a dump is necessary, the SET DUMP ON command can be issued immediately to direct Code Debug TSO to allow the dump to be written if one of the standard dump DD files (SYSUDUMP, SYSMDUMP, or SYSABEND) is allocated to the test session. The dump file can be dynamically allocated just prior to the issuance of the SET DUMP ON command or could have been preallocated through various methods such as the File Allocation Utility (FAU), the TSO ALLOCATE command, JCL if in Batch Connect, etc. (See Using the File Allocation Utility.)