Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 1: Abend Codes


S0C7- Data Exception

S0C7 is the most common COBOL abend. It is a program interrupt (code 7) raised when the CPU tries to do decimal arithmetic on invalid data.

What it means

  • S0C7 means Data Exception: the hardware found data that is not valid packed or zoned decimal during an arithmetic instruction.
  • It is a program interrupt with interrupt code 7, hence the name S0C7.
  • The typical IEF450I message looks like: IEF450I STEP1 - ABEND=S0C7 U0000 REASON=00000007.

Common causes

  • Numeric field used in arithmetic without being initialized, e.g. ADD on a COMP-3 field that still holds spaces or low-values.
  • Moving non-numeric data (like SPACES) to a numeric PIC 9 field and then using it in a calculation.
  • Packed-decimal (COMP-3) field with a bad sign nibble, often from overlaying storage or redefining a group item incorrectly.
  • Reading a file record with alphanumeric data into a record layout that expects numeric fields.

How to find it

  • Code //SYSUDUMP DD SYSOUT=* in the step and rerun to get a formatted dump.
  • In the dump, check the PSW: it points to the failing instruction. The instruction offset tells you which arithmetic statement failed.
  • Look at the general registers and the storage around them to see the bad data, e.g. a COMP-3 field full of spaces (X'40404040').
  • Match the failing offset against the compiler listing to find the exact COBOL statement.

How to fix it

  • Initialize all numeric working-storage fields with VALUE ZERO before using them in arithmetic.
  • Use the IS NUMERIC class test before doing arithmetic on data coming from a file: IF WS-AMT IS NUMERIC.
  • Check the PIC clause and USAGE of the field: make sure COMP-3 fields are really packed decimal in the input.
  • Never MOVE SPACES to a numeric field; MOVE ZERO instead.

Example

  • Code that causes S0C7, and the corrected version:-
    * --- causes S0C7: numeric field holds spaces --- 01 WS-AMT PIC 9(5). MOVE SPACES TO WS-AMT ADD 100 TO WS-AMT *> S0C7: spaces are not numeric * --- corrected version --- 01 WS-AMT PIC 9(5) VALUE ZERO. ADD 100 TO WS-AMT *> works fine





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant