When a DFSORT step fails or produces wrong results, a systematic approach saves time. This page covers how to use SYSOUT messages (including ICE000I), message severity, the DEBUG statement, and checks on control statements and data to find and fix the cause. The goal is to identify whether the failure is due to wrong control statements, bad data, resource limits, or environment (DDs, DCB) and then correct it.
Rather than guessing, follow a consistent order. First, confirm what the step actually ran (ICE000I). Second, find the message that describes the failure (first A or E). Third, verify your control statements against the data and layout. Fourth, use DEBUG or other diagnostics if you need more detail. Fifth, check the environment: DDs, dataset attributes, and input data quality.
| Step | Action | Purpose |
|---|---|---|
| 1 | Check ICE000I | Confirm control statements read from SYSIN; compare to what you intended. |
| 2 | Find first A/E message | Identifies the actual failure (syntax, field, capacity, data exception). |
| 3 | Verify positions and formats | Match SORT/SUM/INREC/OUTREC to record layout; avoid S0C7/S0C4. |
| 4 | Use DEBUG when needed | Get trace/diagnostic output; remove after problem is fixed. |
| 5 | Check DDs and data | Ensure SORTIN/SORTOUT/SORTWKnn exist; validate input data and LRECL/RECFM. |
ICE000I is the first message DFSORT prints. It includes the product and version and, importantly, the control statements that were read from SYSIN. If the wrong PROC is invoked or the wrong dataset is concatenated to SYSIN, the echoed statements will not match what you intended. If a continuation line is in the wrong column (e.g. not in 72 or beyond), the parser may read something different. So the first debugging step is to open the step SYSOUT, find ICE000I, and compare the echoed lines to the SYSIN you meant to use. Mismatches here explain many "wrong result" or syntax-error cases.
DFSORT messages have a severity suffix: I (informational), W (warning), A (application error), E (severe). ICE000I is I—it is not an error. When the step fails, look for the first message with suffix A or E in that step's output. That message usually states the cause: invalid keyword, field out of range, text in wrong column, sort capacity exceeded, or data exception. Read the message text and the associated documentation (IBM Messages and Codes or your site's guide). Do not stop at ICE000I; the failure is reported later.
Many abends and wrong results come from specifying the wrong position, length, or format for a field. DFSORT uses 1-based column positions. A field at columns 21–28 with length 8 must be specified as start=21, length=8. The format must match the data: CH for character, PD for packed decimal, ZD for zoned decimal, BI for binary, and so on. If you specify PD for a field that contains character data (or vice versa), you can get S0C7. If the length or start is off, you may be reading the wrong bytes and get wrong sort order or wrong values in SUM or INREC/OUTREC. Keep a record layout handy and verify every SORT FIELDS=, SUM FIELDS=, INREC, OUTREC, and OUTFIL BUILD= against it.
When the normal messages are not enough, add the DEBUG control statement to SYSIN. DEBUG tells DFSORT to produce additional diagnostic or trace output—for example, how control statements were parsed, record counts at various stages, or sample record content. The exact options depend on your DFSORT product and version; see the DFSORT Messages and Diagnosis or Application Programming guide. Run the job and look at SYSOUT (or the DD used for messages if you use OPTION MSGDDN=) for the extra lines. Use DEBUG only while diagnosing; remove it once the problem is fixed to avoid extra output and overhead in production.
S0C4 (protection exception) can occur with empty input, wrong LRECL or RECFM, or internal limits. Check that SORTIN has the correct DCB and is not corrupt; ensure the file is not empty if the step logic assumes records. S0C7 (data exception) usually means a format or position error in SORT FIELDS, SUM FIELDS, INREC, or OUTREC; verify all specs and the actual data. S322 means the step exceeded the CPU time limit; increase TIME or optimize the step (more sortwork, filtering, or tuning). S013 indicates a data management problem (open failure, DD missing, or DCB mismatch); check all required DDs and dataset attributes. ICE046A means sort capacity exceeded—add or enlarge sortwork datasets or increase FILSZ with DYNALLOC. For each abend, use the message or code with your site's abend documentation and the IBM guides to confirm the cause and remedy.
Ensure all required DD statements are present: SORTIN, SORTOUT, SYSIN, and at least one SORTWKnn (or DYNALLOC). If you use JOINKEYS, the JOINKEYS file DDs must be correct. If you use OUTFIL with multiple outputs, each output DD must be defined. Verify that datasets exist, are not in use by another job, and have the correct DISP. Check LRECL and RECFM: they must match what your control statements assume (e.g. fixed 80-byte records). If the input is variable-length, RECFM should reflect that and your positions must account for the RDW if you reference it. A quick way to rule out data issues is to run with OPTION COPY and perhaps STOPAFT=10 to see if a small subset of records flows through without error.
DFSORT writes its messages to SYSOUT by default—the same logical output stream as the step's JCL SYSOUT. If you use OPTION MSGDDN=ddname, messages go to that DD instead. When you debug, open the dataset that contains the step's messages (often the same as the step listing). Messages usually appear in order: first ICE000I with the control statement echo, then any parsing or setup messages, then processing messages (e.g. record counts), and finally completion or error messages. If the step abends, the last messages before the abend dump are especially important. Learning to scan SYSOUT quickly for ICE000I and then for the first A or E message speeds up diagnosis; the SYSOUT analysis tutorial goes into more detail on how to read and interpret the full output.
A major source of errors is a mismatch between the physical record and what you coded in control statements. Keep a simple record layout (on paper or in a doc): for each field you use in SORT FIELDS, SUM FIELDS, INREC, OUTREC, or OUTFIL, note the starting column (1-based), length, and format (CH, PD, ZD, BI, etc.). When you get a data exception or wrong results, go through this list and verify each value. If your shop uses copybooks or record descriptions, the column numbers may be 0-based in the source; DFSORT uses 1-based positions, so convert carefully. A single wrong digit in a position or length can cause subtle or dramatic failures.
When your sort "game" doesn't work, first look at what instructions the sort program says it got (that's ICE000I). If those are wrong, fix the instructions. Then find the first message that says "something went wrong" (the A or E message)—that tells you what broke. Then check that every number you gave (where a field starts, how long it is, and whether it's a number or letters) matches the real data. If you still don't know, turn on DEBUG so the program prints extra clues. Once you fix the problem, turn DEBUG off so you don't get too much paper.
1. What is the first thing you should check in SYSOUT when a DFSORT step fails?
2. Your step abends with S0C7. What debugging approach is most useful?
3. When should you use the DEBUG statement?
4. What does message severity (I, W, A, E) tell you?
5. How can you confirm that the correct SYSIN was used by the step?