Introduction
Sorting and data transformation are essential operations in enterprise batch processing. IBM's DFSORT utility is the backbone for sorting, merging, filtering, and formatting large datasets efficiently on z/OS.
It plays a critical role in automating business workflows—such as payroll, billing, and report generation—by organizing and manipulating data before further processing. With built-in support, high performance, and rich features, DFSORT is a reliable tool for handling data-heavy jobs in mainframe environments.
Preparation
Create a dataset with LRECL 80, RECFM FB. Here is how record data arranged:
- EmpID starts at position 1, length 5 (zoned decimal).
- Name starts at pos 6, length 20 Character.
- Terminated employee are flag at pos 30, value 'T'.
- Salary at pos 40, length 6, (zoned decimal).
- Dept at pos 60, length 3, Character.
Exercise
Generate the SORT care parameter for following:
- Sort by Employee ID (ascending)
- Sort by Name (descending)
- Remove duplicate records (entire record)
- Filter employees with salary > 50000
- Exclude terminated employees (flag at pos 30, value 'T')
- Copy records skipping first 10
- Copy first 100 records only
- Copy with custom reformat (only Name followed by Salary)
- Replace string 'TEMP' with 'PERM'
- Overlay a fixed string at position 50 with value
VALID
.
- Sort by Department + Salary
- Filter out blank records (first 5 bytes are spaces)
- Total salary by Dept (sum salary, group by Dept)
- INCLUDE records with EMP ID starting with 'AB'
- Split into two output files
- Filter records 10 to 30 only
- IF condition Salary > 80000 → overlay 'VIP' at 60
- Extract records with salary between 30000 and 50000
- Find employees in Dept 'IT' or 'HR'
- Output Name and ID side-by-side
- Append
**
at end of each 70-byte record