THE SHORT ANSWER
S0C7 is IBM's data exception: a decimal instruction met data it cannot use. For the matching Language Environment message CEE3207S, IBM says to check the variables of the failing statement and make sure they were initialized correctly. So: find the statement, find its numeric fields, look at their bytes.
Steps
- Read the failure message. In the job log find S0C7 or CEE3207S ("The system detected a data exception (System Completion Code=0C7)"). Note the program and the step.
- Find the statement. Use your compile listing and the location the message or dump gives you to name the COBOL statement that failed.
- List the numeric fields on that statement. Every field the statement reads is a suspect, including fields it only moves.
- Look at the bytes. A packed (COMP-3) field holds two digits per byte, with the last byte holding one digit and the sign. Spaces, zeros or text there are not a number. Check the field in the dump, or in the file with the tool below.
- Fix the cause, not the symptom. Initialize the field, repair the input, or compile with NUMCHECK, which makes the compiler add numeric class tests on sending fields and report bad data with a message (MSG) or an abend (ABD).
Worked example: spaces in a packed field
The copybook says PIC S9(5) COMP-3, which is 3 bytes. The record holds spaces (X'40') there:
COPYBOOK 05 AMOUNT PIC S9(5) COMP-3.
GOOD 12 34 5C -> 12345
BAD 40 40 40 -> not a numberKit's record decoder reports: Not valid packed decimal: the last half-byte is 0, but it must be a sign (C, F, A or E for positive; D or B for negative). Arithmetic on this field would end with an S0C7 abend.
A letter inside a zoned field is caught the same way: F1 F2 C3 F4 -> Not valid zoned decimal: byte 3 (X'C3') is not a digit (zone must be F). Arithmetic on this field may end with an S0C7 abend.
Related: S0C7 data exception · S0C4 protection or addressing · Abend cheat sheet · Why bad data causes S0C7 (Mainframe Path)
Sources, checked : 0Cx, z/OS 3.2.0 System completion codes; CEE3207S, z/OS 3.2.0 Language Environment runtime messages; NUMCHECK, Enterprise COBOL for z/OS 6.5.0; Formats for numeric data, Enterprise COBOL for z/OS 6.5.0. Explanations are in our own words; the worked example is invented. Confirm against IBM documentation before changing production systems. mainframekit.com/guides/s0c7-where-to-look-first/