Programs bomb. Programs end abnormally. The operating system detects an illegal operation, and cancels your program.
The database management system prevents your program from trying to do something illegal.
The input-output software (access method) detects an inconsistency in one of your files and the way it's defined in your program.
The program is kicked out, and a code is assigned.
Here are links to
z/OS abend codes,
QSAM and VSAM file status keys, and
REXX error codes.