DFSORT

DFSORT Duplicate Claim Detection: Control Cards and Safe Batch Support Practices

Learn practical DFSORT control cards for identifying exact duplicate claim records, preserving evidence, and making safe downstream batch decisions.

Input fileSort keyReview outputControlled flow
Original DBala learning flow — a visual summary of this article’s practical decision path.

Short introduction

Duplicate records are a routine batch-processing problem, not just a data-quality nuisance. A duplicate claim feed can cause duplicate downstream output, inflated control totals, rejected loads, or repeated business processing. DFSORT can identify, retain, or separate duplicates before an application program runs, but the control cards need to match the actual file layout and the operational objective.

Real-world production use case

A nightly claims intake job receives a fixed-block file from an upstream partner. Each 240-byte record contains a claim number in positions 1 through 12, a line number in positions 13 through 15, a transaction type in position 16, and the remaining claim data. The business key is claim number plus line number. The batch cycle must pass one representative record for each unique key to a COBOL validation program and send suspect duplicates to a separate review file.

A support analyst notices that a file is much larger than the prior day, but the scheduler step has not failed. Rerunning the entire cycle without inspection could repeat processing. The safer response is to preserve the original input, confirm the business date and record format, produce counts, identify duplicate keys, and decide with the approved runbook whether duplicates should be rejected, retained once, or escalated to the source team.

Step-by-step explanation

### 1. Define the key from the file layout

Start with the source copybook, interface specification, or approved layout document. For the example, the key is:

CH compares the fields as character data. That is appropriate when identifiers can contain leading zeroes or non-numeric characters. Do not change a key field to binary or zoned-decimal format merely because it looks numeric. A wrong format or offset can group unrelated records and produce a convincing but incorrect output file.

Also confirm whether transaction type belongs in the key. If an adjustment and an original transaction share a claim-and-line number, treating them as duplicates may be wrong. The business interface definition—not a quick JCL assumption—decides this.

### 2. Preserve the incoming file and collect evidence

Never alter the received input in place. Allocate new work and output datasets, keep the original feed available under the normal retention policy, and capture the job ID and cycle date. Before changing the production flow, review the previous successful counts and the current run's record count.

A useful support note records the input dataset, the exact key definition, total input records, unique records, duplicate-key records, and sample duplicate keys if site policy allows. Avoid placing protected claim or member details in broadly visible spool or ticket comments. A count and a safe correlation reference are often sufficient for initial triage.

### 3. Sort records by the business key

DFSORT needs like keys together before it can apply a duplicate action. SORT FIELDS=(1,12,CH,A,13,3,CH,A) orders records by claim number and then line number. The data is not deduplicated just because it was sorted; a separate SUM, SELECT, XSUM, or reporting technique controls what is retained or emitted.

For a full production flow, select an appropriate work-space allocation and let the local SORT procedure provide standard options. Do not copy site-specific SORTWKnn allocations or tuning values from another job without checking capacity and standards.

### 4. Separate exact duplicates from duplicate keys

For exact duplicate records, SUM FIELDS=NONE after a sort removes duplicate records that are identical across the full record. It retains one copy. This is useful only when the interface contract explicitly says repeated identical records are safe to collapse.

For duplicate keys that might have different non-key content, use a key-focused report or an XSUM strategy with care. XSUM writes records discarded by SUM to a second dataset. With SUM FIELDS=NONE, that second file represents exact duplicate records, not every record with a repeated key. If the requirement is to identify all occurrences of a repeated key, including the first one, use a separate validation/reporting design or an application routine that compares adjacent sorted keys and marks each occurrence.

That distinction avoids a common support error: reporting only the second occurrence and describing the file as a complete duplicate-key population.

### 5. Gate the downstream application deliberately

A duplicate output file does not automatically mean the main application should proceed. The runbook should define a threshold and owner decision. For example, zero duplicate records may allow normal flow; a small expected resend population may continue after approval; conflicting duplicate keys may stop the cycle for source-data review.

Use return codes and scheduler dependencies to make that decision visible. Do not merely write a duplicate report and allow an update program to run without anyone checking it. If the downstream COBOL program can update DB2 or VSAM, it also needs its own restart, audit, and idempotency controls.

Example JCL and DFSORT control cards

This illustrative job creates a de-duplicated work file and writes discarded exact duplicates to DUPRPT. It assumes fixed 240-byte records and uses claim number plus line number only for sort order. Because SUM FIELDS=NONE treats whole-record matches as duplicates, records with the same key but different content remain in UNIQUEOUT for further business validation.

//CLMDUP   JOB (ACCT),'CLAIM DUP CHECK',CLASS=A,MSGCLASS=X
//DUPCHK   EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=ACME.CLAIMS.INBOUND.D20261019,DISP=SHR
//SORTOUT  DD DSN=ACME.CLAIMS.WORK.DEDUP.D20261019,
//            DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(20,10)),
//            DCB=(RECFM=FB,LRECL=240,BLKSIZE=0)
//XSUM     DD DSN=ACME.CLAIMS.REVIEW.EXACTDUP.D20261019,
//            DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(5,2)),
//            DCB=(RECFM=FB,LRECL=240,BLKSIZE=0)
//SYSIN    DD *
  SORT FIELDS=(1,12,CH,A,13,3,CH,A)
  SUM FIELDS=NONE
  XSUM
/*

After the step, inspect SORTOUT and XSUM counts in the sort messages. The output names and space quantities are examples, not a recommendation for a specific environment. A later validation step can compare control totals and investigate same-key/different-content records before the records reach an update process.

Common mistakes

Practical checklist

Summary

DFSORT is a strong first control for batch input quality when its key definition and output semantics are understood. Sort by verified business fields, preserve the original feed, distinguish exact duplicates from conflicting duplicate keys, and make the downstream decision explicit. The safest production-support outcome is not simply a smaller file: it is a traceable result that tells the team what was received, what was separated, and whether further business review is needed before processing continues.

← Back to all articles