Masking a Batch Diagnostic Extract with DFSORT Before It Leaves the Support Team
A batch failure often requires a small record-level extract to explain a mismatch, but copying the original input file into a ticket or email can expose data that the recipient does not need. This tutorial shows a controlled DFSORT pattern for retaining the fields needed for diagnosis while masking or omitting sensitive fields.
A batch failure often requires a small record-level extract to explain a mismatch, but copying the original input file into a ticket or email can expose data that the recipient does not need. This tutorial shows a controlled DFSORT pattern for retaining the fields needed for diagnosis while masking or omitting sensitive fields.
The example is fictional. Record positions, data classifications, retention rules, and permitted destinations differ by organization. Treat the output as a diagnostic work product, not as approval to distribute production data.
Goal: answer a support question without exporting the whole record
Suppose an overnight policy interface produces rejects because the receiving application sees an unknown product code. Support needs enough information to determine whether the source sent an unsupported code, which run produced it, and how many records are affected. They do not need the member name, address, account identifier, or full monetary amount.
A narrow diagnostic record can carry only these items:
| Output field | Purpose | Handling |
| --- | --- | --- |
| Run date | Ties evidence to the processing event | retain |
| Source sequence | Locates the record in the controlled input | retain |
| Product code | Explains the reject condition | retain |
| Member ID | Supports correlation if approved | keep last four characters only |
| Amount | Helps identify format issues | replace with a fixed mask or omit |
| Name and address | Not needed for this question | omit entirely |
This is more useful than a full-file copy and safer than relying on memory or a manually edited screenshot. The design decision comes first: define the question, the minimum fields that answer it, and the approved audience. A technically masked file can still be inappropriate if it is placed in a broadly accessible queue or retained indefinitely.
Establish the input layout before writing control cards
Assume a fixed 160-byte fictional input record. The relevant positions are:
| Positions | Field | Format |
| --- | --- | --- |
| 1-8 | cycle date | YYYYMMDD character digits |
| 9-15 | source sequence | 7 character digits |
| 16-27 | member ID | 12 characters |
| 28-57 | member name | 30 characters |
| 58-97 | address | 40 characters |
| 98-101 | product code | 4 characters |
| 102-112 | premium amount | 11 characters, implied decimals |
| 113-160 | other detail | site-defined |
Do not take positions from an old copybook or a spreadsheet alone. Confirm the record layout actually used by the failed program and the dataset attributes of the selected input generation. A layout shift can make a masking card reveal the wrong bytes or replace a harmless field while leaving a sensitive field visible.
Also decide whether the extract should contain every record or only known exceptions. For an existing reject file, the input may already be scoped. If it is the original feed, use a documented selection condition such as the reject code or a controlled sequence range. Avoid generating a large “just in case” diagnostic file.
Worked DFSORT pattern
This example takes a 160-byte reject record and builds a 26-byte review line. It preserves the cycle date, source sequence, product code, and the rightmost four characters of the member ID. It deliberately does not copy the name, address, amount, or remaining detail.
//MASKDIAG EXEC PGM=SORT
//SORTIN DD DSN=APP.POLICY.REJECTS.D20261110,DISP=SHR
//SORTOUT DD DSN=&&MASKED,DISP=(NEW,PASS),
// SPACE=(TRK,(5,2)),UNIT=SYSDA,
// DCB=(RECFM=FB,LRECL=26,BLKSIZE=0)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,8,CH,A,9,7,CH,A)
INREC BUILD=(1,8,C' ',9,7,C' ',98,4,C' ',24,4)
/*
The last operand, 24,4, selects bytes 24 through 27 of the original record: the final four characters of the 12-byte member ID at positions 16 through 27. The resulting output layout is:
positions 1-8 cycle date
position 9 blank
positions 10-16 source sequence
position 17 blank
positions 18-21 product code
position 22 blank
positions 23-26 member-ID suffix
The output LRECL is 26. Eight bytes plus three separator blanks plus seven, four, and four retained bytes equals 26 bytes. Calculate the layout explicitly; do not assume a generated record is the same length as its input.
A fictional output line might look like this:
20261110 0001842 PX17 4821
It lets an authorized reviewer compare a date, sequence, product code, and controlled identifier suffix with the application’s reject reason. It cannot recreate the name, address, full identifier, or amount from the diagnostic line itself.
Failure cases that weaken a masking design
Masking is not the same as selecting. Replacing a few fields with asterisks while copying the rest of a 160-byte record may retain unreviewed sensitive fields in comments, free text, or reserved positions. Build a new, minimal record instead.
Last four is not always safe. A short identifier suffix can be enough to identify a person when combined with date, product, or other data. If the support question can be answered with only a source sequence, omit the identifier suffix too. Follow the data owner’s classification rule, not a generic convention.
A temporary dataset still needs controls. &&MASKED limits the dataset to the job, but it can still appear in spool-related evidence or be passed to a later step. If the output must be retained, use an approved dataset name, access control, retention period, and deletion process. Do not use a personal dataset or an open shared location as a shortcut.
Control cards can be wrong even when SORT returns RC=0. DFSORT can execute successfully while a field position is off by one. A clean return code proves the utility processed bytes; it does not prove that those bytes have the intended meaning.
What to verify before sharing the extract
- Confirm the exact resolved input dataset, business date, record format, and current layout version.
- State the support question and list each output field that is necessary to answer it; remove everything else.
- Have a reviewer independently check the input positions and the calculated output
LRECLagainst the control card. - Run the card against approved test or masked sample data first, then inspect several output lines for accidental exposure and correct field alignment.
- Compare the extract count with the selected reject population; do not mistake a partial extract for the full exception count.
- Verify the intended recipient, approved transfer path, and retention/deletion requirement before moving any output outside the restricted support area.
- Keep the original failure evidence under its normal controls. Do not alter, delete, or rerun the source job merely to create a better diagnostic extract.
Practical takeaway
DFSORT can turn a sensitive batch record into a small, reviewable evidence line, but only when the team designs from the diagnostic question backward. Select the minimum fields, build a fresh output record rather than copying and hiding fields, validate every position, and control the resulting file as carefully as the investigation requires.