MainframeMaster

Common Abends

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.

Diagnostics & Debugging
Progress0 of 0 lessons

How to Use This Page

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).

Quick Reference: Common Abends

Common DFSORT abends and typical fixes
CodeTypical causeWhat to try
S0C4Protection exception; invalid storage referenceCheck LRECL/RECFM, empty input, product limits; apply PTFs if known.
S0C7Data exception; wrong format or invalid numeric dataVerify position/length/format in SORT, SUM, INREC, OUTREC; match format to data (PD/ZD/CH).
S322CPU time limit exceededIncrease TIME in JCL or reduce work (more sortwork, larger region).
S013Data management (open/failure) on a datasetCheck all DDs present, dataset exists, DCB matches (LRECL, RECFM).
ICE046ASort capacity exceeded; not enough sortworkAdd SORTWKnn or increase space; with DYNALLOC increase FILSZ.
SB37Out of space on a dataset (e.g. SORTOUT or SORTWK)Increase SPACE= (primary/secondary) on the failing DD.

S0C4 — Protection Exception

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 — Data Exception

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 — Time Limit Exceeded

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 — Data Management Error

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 — Sort Capacity Exceeded

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 Other Space Abends

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.

General Diagnosis Steps

  • Note the abend code (e.g. S0C7) and the step that failed.
  • Read the step SYSOUT from the beginning: ICE000I shows the control statements that were used.
  • Read the last ICE messages before the abend; the last A-level or error message often states the cause.
  • Look up the abend code in your site's abend manual and the IBM DFSORT Messages, Codes and Diagnosis Guide.
  • Fix the cause (syntax, format, position, resources, DCB) and rerun. If the abend persists, capture a dump if your site allows and compare with vendor documentation or support.

Explain It Like I'm Five

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.

Exercises

  1. Your step abends S0C7. You have SUM FIELDS=(50,8,PD). Your record layout says bytes 50–57 are character (product name). What is the likely cause and how do you fix it?
  2. You get ICE046A. You are using OPTION DYNALLOC and FILSZ=E1000000. Your input has 10 million records of 200 bytes each. What should you do?
  3. After a sort step abends, where do you look first for the reason (abend code and messages), and what manual do you use to interpret them?

Quiz

Test Your Knowledge

1. What does abend S0C7 usually indicate in a DFSORT step?

  • Insufficient sortwork
  • A data exception: the program tried to use data in an invalid way (e.g. wrong format—treating packed as character, or invalid numeric digits). Often caused by wrong position/length/format in SORT FIELDS, SUM FIELDS, or INREC/OUTREC
  • Time limit exceeded
  • Dataset open failure

2. Your sort step abends with S322. What is a likely cause?

  • Wrong REFORMAT
  • CPU time limit exceeded—the step ran longer than the region or job time limit allowed
  • SORTOUT full
  • S0C4 only

3. What does S0C4 in a DFSORT step often indicate?

  • Sort capacity exceeded
  • A protection or addressing exception: the program referenced invalid storage (e.g. bad pointer, wrong length). In sort context this can be caused by empty or corrupt input, wrong record length (LRECL), or internal limits exceeded
  • Data exception
  • Open failure

4. You get ICE046A (sort capacity exceeded). What should you do?

  • Ignore it
  • Increase sortwork: add more SORTWKnn datasets or give them more space; or if using DYNALLOC, increase FILSZ so DFSORT requests enough work space
  • Reduce SORTIN
  • Change SORT FIELDS only

5. S013 abend during a sort step often indicates what?

  • CPU time
  • A data management (open/close) problem: e.g. dataset could not be opened, DCB mismatch, or problem with a DD (e.g. SYMNAMES, wrong DISP or missing dataset)
  • Wrong INCLUDE
  • SUM overflow only