Sample DFSORT JCL to Sort Three Input Files

DFSORT is the top sorting-utility in the Mainframe, which is best in creating reports. You can do reporting tasks quickly – if you know its correct usage.


The big usage of DFSORT utility, you can find in all financial projects – Banking, Capital Market and Insurance.

DFSORT Example JCL With Explanation.

//EXAMP  JOB A123,PROGRAMMER 
//S1 EXEC PGM=SORT 
//SYSOUT  DD SYSOUT=A 
//SORTIN  DD DSN=INPUT.FILE1,DISP=SHR
//        DD DSN=INPUT.FILE2,DISP=SHR
//        DD DSN=INPUT.FILE3,DISP=SHR
//SORTOUT DD DSN=OUTPUT.FILE,
//           DISP=(NEW,CATLG,DELETE),
//           SPACE=(CYL,(5,5)),
//           UNIT=SYSDA 
//SYSIN   DD *   
INREC IFTHEN=(WHEN=
(1,3,CH,EQ,C'HDR'),
OVERLAY=(6:YDDD=(D4/),
81:C'0',82:SEQNUM,2,ZD)),
/*IFTHEN works on header record 
IFTHEN=
(WHEN=(1,3,CH,EQ,C'TRL'),
OVERLAY=
(11:YDDD=(D4/),81:C'9',
82:SEQNUM,2,ZD)), 
/*IFTHEN works on trailer record
IFTHEN=
(WHEN=NONE,OVERLAY=(81:C'1'))
/*IFTHEN works on details records 
SORT FIELDS=
(81,1,CH,A,8,5,CH,A) 
/*Sorts input record OUTFIL REMOVECC,
/*REMOVECC removes the ANSI 
/*carriage control 
/*characters and ensures that the 
/*RECFM is FB
/*rather than FBA
OMIT=
(81,1,SS,EQ,C'0,9',
AND,82,2,ZD,GT,+1), 
/*This Omits records matching 
/*to the given criteria
OUTREC=(1,80)
//

Keep Reading

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.