Quiz — Chapter 33: Debugging Strategies
Multiple Choice
1. What abend code indicates a data exception (non-numeric data in a packed decimal field)? - a) S0C1 - b) S0C4 - c) S0C7 - d) S322
2. Which compiler option checks that table subscripts are within declared bounds at runtime? - a) CHECK - b) SSRANGE - c) TEST - d) OPTIMIZE
3. What is the purpose of the LIST and MAP compiler options? - a) They generate debug symbols for interactive debuggers - b) They produce assembly listings and storage maps for dump analysis - c) They enable READY TRACE functionality - d) They optimize the generated code
4. What does READY TRACE do? - a) Starts the interactive debugger - b) Displays the name of every paragraph as it is entered - c) Traces all SQL calls - d) Writes a memory dump
5. In a CEEDUMP, what information is most useful for locating a bug? - a) JCL parameters - b) Statement number, variable values, and call traceback - c) File allocation information - d) CPU usage statistics
6. What abend code indicates that a program ran too long (likely an infinite loop)? - a) S0C7 - b) S0C4 - c) S322 - d) S806
7. Which tool allows you to intercept EXEC CICS commands during execution? - a) DSNTEP2 - b) SPUFI - c) CEDF - d) IDCAMS
8. A group-level MOVE in COBOL does NOT perform: - a) Character padding with spaces - b) Numeric conversion between data types - c) Left-to-right byte copying - d) Length truncation
9. What SQLCODE indicates "not found" (no rows returned)? - a) 0 - b) +100 - c) -204 - d) -811
10. Which of the following is the BEST first step when debugging a production abend? - a) Add DISPLAY statements and recompile - b) Record the abend code, module name, and offset - c) Restart the program and hope it works - d) Call the DBA
True/False
11. SSRANGE has zero runtime performance overhead. True / False
12. A S0C4 abend typically indicates accessing storage outside your address space. True / False
13. DISPLAY debugging should always be removed from production code. True / False
14. In COBOL, moving a display-numeric field to a COMP-3 field via a group MOVE performs proper numeric conversion. True / False
15. CEDF can only be used with batch programs. True / False
Short Answer
16. Explain the difference between a group MOVE and an elementary MOVE when the target is a COMP-3 (packed decimal) field. Why is this distinction critical for avoiding S0C7 abends?
17. A program abends with S0C7 on the statement ADD WS-FEE TO WS-TOTAL. Describe the step-by-step process you would follow to diagnose which field contains invalid data using the dump and compiler listing.
18. What is the advantage of using debug levels (0-9) controlled by a runtime parameter instead of simply adding/removing DISPLAY statements for each debugging session?
19. Describe a scenario where a COBOL program produces incorrect results but does NOT abend. How would you approach debugging this type of problem?
20. A COBOL program receives data from a Java application via MQ. The COBOL program abends with S0C7 when processing a numeric field. The Java programmer insists the data is correct. What cross-platform data representation issue might cause this, and how would you verify it?
Answer Key
- c — S0C7 is the data exception (packed decimal operation on non-numeric data).
- b — SSRANGE checks subscript bounds at runtime.
- b — LIST produces assembly listings; MAP shows storage layouts; both essential for dump analysis.
- b — READY TRACE displays paragraph names as they are entered during execution.
- b — CEEDUMP's statement number, variable values, and traceback directly locate the bug.
- c — S322 indicates the job exceeded its time limit.
- c — CEDF (CICS Execution Diagnostic Facility) intercepts EXEC CICS commands.
- b — Group MOVEs are character (byte) moves with no numeric conversion.
- b — SQLCODE +100 indicates no rows found.
- b — Always start by recording the diagnostic information (abend code, module, offset).
- False — SSRANGE adds 5-15% runtime overhead for bounds checking.
- True — S0C4 (protection exception) occurs when accessing invalid memory addresses.
- False — Conditional debug displays (controlled by debug level) can and should remain in production code, controlled by a runtime parameter.
- False — Group MOVEs copy bytes without conversion. Only elementary MOVEs perform numeric conversion.
- False — CEDF is specifically for CICS (online) programs, not batch.
- An elementary MOVE from display numeric to COMP-3 converts the data representation (e.g., F1F2F3 display to 01 23 3C packed). A group MOVE copies raw bytes without conversion, leaving the COMP-3 field containing display-format bytes, which are not valid packed decimal. This causes S0C7 on any subsequent arithmetic operation.
- (1) Get the offset from the abend message. (2) Find that offset in the compiler listing (compiled with LIST/OFFSET) to identify the statement. (3) Use the MAP listing to find the displacement of WS-FEE and WS-TOTAL. (4) Find those displacements in the dump. (5) Check each field's hex representation for valid packed decimal format (each nibble 0-9, last nibble C/D/F for sign). The field with invalid hex content is the culprit.
- Debug levels allow you to leave diagnostic code in the program permanently and activate it at runtime without recompiling. This means diagnostics are always available for production issues, multiple verbosity levels provide flexibility, and you avoid the risk of introducing new bugs when adding/removing DISPLAY statements.
- For incorrect results without abends: (1) Identify where output diverges from expected. (2) Trace backward from the first wrong output. (3) Add DISPLAY statements at decision points (IF/EVALUATE) to see which branches execute. (4) Inspect input data for unexpected values. (5) Check for silent truncation, group-move issues, or incorrect comparison logic.
- Java uses null-terminated strings and may send numeric data in ASCII encoding. COBOL on z/OS expects EBCDIC encoding and space-padded fields. A numeric field containing ASCII digits (hex 30-39) instead of EBCDIC digits (hex F0-F9) will cause S0C7. Verify by examining the hex content of the field in the dump. Fix by applying INSPECT CONVERTING or ensuring the MQ channel performs ASCII-to-EBCDIC conversion.