A S0C7 data exception occurs in an Easytrieve program when non-numeric data is placed in a numeric field. The following program contains a deliberate data exception:
1 PARM LINK(EZTEST10 R) DEBUG (STATE FLOW)
2 FILE PERSNL1 FB (150 1800)
3 NAME-LAST 17 8 A HEADING('LAST' 'NAME')
4 NAME-FIRST 25 8 A HEADING('FIRST' 'NAME')
5 PAY-GROSS 94 4 P 2 HEADING('GROSS' 'PAY')
6 *
7 WS-DATA-EXCEPTION W 5 A
8 WS-NUMBER WS-DATA-EXCEPTION 5 P 0
9 *
10 JOB INPUT PERSNL1
11 WS-DATA-EXCEPTION = ' '
12 WS-NUMBER = WS-NUMBER + 1
13 PRINT RPT1
14 REPORT RPT1 LINESIZE 80
15 TITLE 01 'EZTEST10 - CONTROL BREAK ON DEPT'
16 LINE 01 PERSNL1:NAME-FIRST +
PERSNL1:NAME-LAST +
PERSNL1:NAME-LAST +
PERSNL1:PAY-GROSS +
WS-NUMBER
How does one find the statement that caused the S0C7 data exception?
Easytrieve Report Generator, release 11.6.01
Looking at the coding example above, WS-DATA-EXCEPTION is a 5-byte alphabetic field that is redefined by the packed numeric field WS-NUMBER.
WS-DATA-EXCEPTION is set to 5 hex '40' blanks and then WS-NUMBER is computed by adding 1.
This is a classic formula for an S0C7 data exception.
If this happened to be a very large program with pages and pages of code you may need to review the following two methods to determine which instruction caused the S0C7.
12 *******A006 PROGRAM INTERRUPT - CODE 7 (DATA EXCP)
This indicates that the error occurred at statement number 12 and that the error was an S0C7 data exception.
FLOW caused the following to print:
FLOW TABLE - MAXIMUM ENTRIES 100
10 11 12
This indicates that statements 10, 11, and 12 were executed just prior to the S0C7.
Register 3 in the sample program dump is 7D80, as the following illustrates:
R0 0000000C R1 00000006 R2 00007C95 R3 00007D80
R8 00000000 R9 000069B0 R10 80015636 R11 00008D70
Add 7D80 to hex '4E', get 7DCE. Go to hex 7DCE in the dump
00007DC0 00009A8E 00010000 00000000 0000000C
The value at 7DCE is hex C. Convert hex C to decimal and you get 12. Statement 12 is the statement number that caused the S0C7 data exception.