Simple Mainframe Universe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

COBOL Troubleshooting


S0C9 divide exception

S0C9 is a fixed-point divide exception: the program divided a binary field by zero (or the quotient overflowed).

What it means

  • Integer division by zero in a COMP field raises S0C9.
  • It can also fire when the quotient does not fit the result field.

Common causes

  • Divisor field is zero because input data had zeros or spaces.
  • Divisor never initialized.
  • Quotient larger than the receiving field allows.

How to diagnose

  • Locate the DIVIDE statement; display the divisor value at failure.
  • Trace where the divisor is populated — file, calculation, or parameter.

How to fix it

  • Test the divisor for zero before dividing.
  • Validate input data so zero divisors are rejected or defaulted.

Example: Never divide without a zero test

IF WS-DIVISOR NOT = ZERO DIVIDE WS-DIVISOR INTO WS-AMOUNT ON SIZE ERROR DISPLAY "Divide overflow" END-DIVIDE ELSE DISPLAY "Zero divisor rejected" END-IF.

A zero test before DIVIDE eliminates S0C9.

Interview tip

  • Q: How would you troubleshoot a S0C9 divide exception in production?
  • A: I would display the divisor at failure, trace its source, and add a zero test plus input validation.

Prevention checklist

  • Validate divisors from external data.
  • Add ON SIZE ERROR to DIVIDE.




© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant