Tags

, , , , , , , , ,

ICETOOL (DFSORT) has an operator DATASORT which can be used in SORT control statements to sort the detail records while keeping the header(s) (First N records) and trailer(s) (Last N records) intact.

//STEP01 EXEC PGM=ICETOOL
//SYSPRINT DD SYSOUT=*
//INFILE DD DISP=SHR,DSN=YOUR.INPUT.FILE
//OUTFILE DD DSN=YOUR.OUTPUT.FILE,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(5,1),RLSE),
// DCB=(RECFM=FB,LRECL=30,BLKSIZE=0)
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLIN DD *
* Sort detail records between the header and trailer
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)
//CTL1CNTL DD *
* Sort the detail records ascending by positions 1-3.
SORT FIELDS=(1,3,CH,A)
/*

Ex:
Input File

20170612-03.00.00
444
111
333
222
20170612-04.00.00

Output File

20170612-03.00.00
111
222
333
444
20170613-04.00.00

Note:
If you have multiple headers(2) and trailers(3), DATASORT can look as below

DATASORT FROM(IN1) TO(OUT1) HEADER(2) TRAILER(3) USING(CTL1)

Advertisements