DFSORT is the best utility to create reports in the Mainframe. Here is a sample DFSORT JCL to sort three files. And this utility is being used In all financial projects in 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