0% found this document useful (0 votes)
92 views2 pages

Mainframe SORT Utilities Guide

The document serves as a reference guide for SORT utilities (DFSORT or SYNCSORT) on IBM Mainframes, detailing their use for data manipulation tasks such as sorting, merging, and filtering datasets. It outlines the basic JCL structure for executing SORT operations, common control statements, and advanced features like JOINKEYS and ICETOOL. Best practices for using SORT utilities are also provided, emphasizing the importance of checking output statistics and optimizing for large datasets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views2 pages

Mainframe SORT Utilities Guide

The document serves as a reference guide for SORT utilities (DFSORT or SYNCSORT) on IBM Mainframes, detailing their use for data manipulation tasks such as sorting, merging, and filtering datasets. It outlines the basic JCL structure for executing SORT operations, common control statements, and advanced features like JOINKEYS and ICETOOL. Best practices for using SORT utilities are also provided, emphasizing the importance of checking output statistics and optimizing for large datasets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Mainframe SORT – Reference & Guide

Introduction
SORT utilities (DFSORT or SYNCSORT) are powerful tools on IBM Mainframes used for:
- Rearranging data in sequential/VSAM datasets
- Selecting/omitting records
- Summarizing, merging, joining datasets
- Reformatting records

They are used in JCL steps for data manipulation without writing COBOL/PL1 programs.

Basic JCL Structure


//JOBNAME JOB (ACCT),'SORT EXAMPLE'
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=[Link],DISP=SHR
//SORTOUT DD DSN=[Link],DISP=NEW,CATLG,UNIT=SYSDA,SPACE=(CYL,(5,5))
//SYSIN DD *
SORT FIELDS=(1,10,CH,A)
/*

Key DD Statements:
- SORTIN → Input dataset
- SORTOUT → Output dataset
- SYSIN → Control statements (defines sort/merge/filter logic)
- SYSOUT → Messages and statistics

Common Control Statements


1. Sorting Records:
SORT FIELDS=(1,10,CH,A)

2. Merging Datasets:
MERGE FIELDS=(15,5,CH,A)

3. Copying Records (No Sort):


SORT FIELDS=COPY

4. Filtering Records:
INCLUDE COND=(20,3,CH,EQ,C'ABC')
OMIT COND=(50,2,CH,EQ,C'99')

5. Summarizing Data:
SUM FIELDS=(30,5,BI)

6. Reformatting Output:
OUTREC FIELDS=(1,10,15,5,30,5)

7. Removing Duplicates:
SORT FIELDS=(1,10,CH,A)
SUM FIELDS=NONE

Advanced Features
- JOINKEYS → Join two datasets on a common key (like SQL JOIN)
- INREC / OUTREC → Modify record layout before/after sort
- WHEN=INIT / WHEN=GROUP → Grouping and sequencing
- ICETOOL → Reporting, counts, min/max, data analytics

Example – Remove Duplicates and Keep Highest Value


//SYSIN DD *
SORT FIELDS=(1,10,CH,A,11,5,BI,D)
SUM FIELDS=NONE
/*

Sort by key (1–10), then numeric field (11–15) descending.


Keeps only the highest value per key.

Best Practices
- Always check SYSOUT for sort statistics
- Use DFSORT symbols for readability
- For very large datasets, tune memory (REGION) and SORTWKxx datasets

References
- IBM DFSORT Guide
- SYNCSORT User Manual
- JCL Reference for DD statements

You might also like