Module 1: Abend Codes
S322- CPU Time Exceeded
S322 means the job step used up all the CPU time it was allowed. The most common cause is a program stuck in an infinite loop.
What it means
- S322 means the step exceeded its CPU TIME limit and was terminated by the system.
- The limit comes from the TIME parameter on the JOB or EXEC statement. TIME=1440 means 1440 minutes (24 hours); smaller values are common for test jobs.
- The typical message in the job log is: IEF450I STEP1 - ABEND=S322 U0000 REASON=00000000, after the step has been running a long time.
Common causes
- An infinite loop in the program: a PERFORM loop whose exit condition never becomes true, or a paragraph that branches back to itself.
- Reading a file without ever hitting end-of-file because the AT END condition is missing.
- A genuinely long-running program that simply needs more CPU time than the TIME limit allows.
- A loop waiting on a resource that never becomes available, e.g. a dataset held by another job.
How to find it
- Check the job log: the step ran for a long time and then ended with S322. That pattern points to a loop.
- Look at the program logic around loops: PERFORM ... UNTIL conditions, GO TO loops, and file-read loops.
- If a dump is available, the PSW shows where the program was spinning when time ran out.
How to fix it
- Fix the loop: make sure every loop has a working exit condition, and every file read has an AT END clause.
- Add a loop counter with a safety exit while testing, so a runaway loop stops itself.
- Only after confirming the program is healthy, increase the TIME limit on the JOB or EXEC statement.
- For a long batch program, split the work or run it with a realistic TIME value agreed with operations.
Example
- Set the TIME limit at step level (minutes,seconds) and at job level:-
//MYJOB JOB (ACCT),'TEST',TIME=10 //STEP1 EXEC PGM=MYPROG,TIME=(5,0) //* //* TIME=(5,0) = 5 minutes CPU for this step. //* TIME=10 on the JOB = 10 minutes CPU for the whole job.
