When a DFSORT step fails with an abend (abnormal end), the abend code (e.g. S0C4, S0C7, S322) and the ICE messages in SYSOUT tell you what went wrong. This page summarizes common abends you may see in sort steps, their typical causes, and what to do. It is not a substitute for your site's abend manual or the IBM z/OS DFSORT Messages, Codes and Diagnosis Guide—always look up the exact code for your environment—but it gives you a starting point for diagnosis and fix.
When your step abends, note the abend code from the job output (e.g. S0C7) and open the step's SYSOUT to read the last ICE messages. The message (e.g. ICE201A) and the abend code together usually point to the cause. Use the table below as a quick reference; then look up the code in your abend manual and the DFSORT Messages and Codes guide for the exact explanation and programmer response. Fixes often involve correcting control statement syntax (position, length, format), adding resources (sortwork, time, space), or fixing dataset attributes (DCB, DISP).
| Code | Typical cause | What to try |
|---|---|---|
| S0C4 | Protection exception; invalid storage reference | Check LRECL/RECFM, empty input, product limits; apply PTFs if known. |
| S0C7 | Data exception; wrong format or invalid numeric data | Verify position/length/format in SORT, SUM, INREC, OUTREC; match format to data (PD/ZD/CH). |
| S322 | CPU time limit exceeded | Increase TIME in JCL or reduce work (more sortwork, larger region). |
| S013 | Data management (open/failure) on a dataset | Check all DDs present, dataset exists, DCB matches (LRECL, RECFM). |
| ICE046A | Sort capacity exceeded; not enough sortwork | Add SORTWKnn or increase space; with DYNALLOC increase FILSZ. |
| SB37 | Out of space on a dataset (e.g. SORTOUT or SORTWK) | Increase SPACE= (primary/secondary) on the failing DD. |
S0C4 means the program referenced storage it was not allowed to access (invalid address or length). In DFSORT this can happen when the input file is empty and a code path does not handle zero records, when the record length (LRECL) or RECFM does not match what DFSORT expects so it reads or writes the wrong amount of data, or when internal limits are exceeded. Check that SORTIN (and SORTOUT) have the correct DCB: LRECL and RECFM must match the actual data. If the file can be empty, some sites use a dummy record or a prior step to avoid feeding an empty file; check your product documentation for empty-file handling. If the vendor has documented S0C4 fixes for certain scenarios, apply the relevant PTF.
S0C7 occurs when the program uses data in an invalid way—for example, interpreting bytes as a packed decimal number when they are not valid packed (e.g. character data, or an invalid sign nibble). In sort steps the most common cause is wrong position, length, or format in a control statement. If you specify SUM FIELDS=(20,4,PD) but the bytes at 20–23 are character (e.g. a name), DFSORT will try to treat them as packed and can S0C7. Similarly, SORT FIELDS= with the wrong format, or INREC/OUTREC building or copying a field with the wrong format, can cause S0C7. Fix by verifying every (position, length, format) in SORT FIELDS=, SUM FIELDS=, INREC, OUTREC, and OUTFIL BUILD= against your record layout or copybook. Use PD for packed (COMP-3), ZD for zoned (DISPLAY numeric), CH for character. If the data itself is bad (e.g. non-numeric in a numeric field), add INCLUDE/OMIT to skip invalid records or cleanse the input in a prior step.
S322 means the step exceeded its CPU time limit (or the job/region time limit). Large sorts, merge steps, or join steps that process a lot of data can run for a long time. To fix: increase the TIME parameter on the JCL EXEC statement (e.g. TIME=60 for 60 minutes) or on the job card so the step is allowed more CPU time. You can also try to make the sort faster so it finishes within the limit: provide more sortwork (SORTWKnn or DYNALLOC with a sufficient FILSZ) and a larger REGION so that DFSORT uses more memory and does less I/O. See the performance tuning, sortwork datasets, and dynamic allocation tutorials.
S013 is typically a data management (open/close) failure. The step could not open a dataset or encountered a DCB or allocation problem. Check that every required DD is present: SORTIN, SORTOUT, SYSIN, and for a sort (not COPY) either SORTWKnn or OPTION DYNALLOC. For JOINKEYS you need SORTJNF1 and SORTJNF2; for OUTFIL you need a DD for each FNAMES= name. Ensure each dataset exists (or is created with DISP=(NEW,...)) and is not in use by another job. Ensure DCB (LRECL, RECFM, BLKSIZE) matches what DFSORT will read or write. If you use SYMNAMES or other special DDs, verify they are correct. See required DD statements and SORTIN/SORTOUT tutorials.
ICE046A means DFSORT did not have enough sortwork space to complete the sort. The work datasets (SORTWKnn or dynamically allocated work) were insufficient for the volume of data. Fix by adding more SORTWKnn DD statements or by increasing the SPACE= (primary and secondary) on existing SORTWKnn datasets. If you use OPTION DYNALLOC, DFSORT allocates work based on FILSZ; if FILSZ is too low, it requests too little space. Increase FILSZ to a realistic value (or slightly high) for your input size. See the sortwork datasets and dynamic allocation tutorials for how to estimate and allocate sortwork.
SB37 (and related codes) means a dataset ran out of space during the step—often SORTOUT or a SORTWK dataset. Increase SPACE= on the failing DD: use a larger primary and secondary quantity so the dataset can extend. For SORTOUT, estimate the number of output records and the record length and allocate enough space. For sortwork, see the sortwork datasets tutorial. If you use dynamic allocation, increasing FILSZ can lead DFSORT to request larger work datasets.
When the sort program runs, sometimes it stops with a special code (like S0C7 or S322). That code is like a short note saying what went wrong. S0C7 often means "you told me this was a number but it wasn't"—so we fix it by checking that we said the right kind of number (packed or zoned) for each field. S322 means "time ran out"—so we give the step more time or make the sort faster. S013 means "I couldn't open a file"—so we check that every file the step needs is there and has the right size. The book of codes (abend manual) tells us exactly what each code means and what to do.
1. What does abend S0C7 usually indicate in a DFSORT step?
2. Your sort step abends with S322. What is a likely cause?
3. What does S0C4 in a DFSORT step often indicate?
4. You get ICE046A (sort capacity exceeded). What should you do?
5. S013 abend during a sort step often indicates what?