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)

——————————————————————————————————–

If you would like to Earn Free Stocks, Credit card Points and Bank account Bonuses, Please visit My Finance Blog

——————————————————————————————————–

You may also like to look at:

Working on Mainframes – Is Change to a different technology necessary
Important SQL CODES and ABEND CODES
SORT JOIN – TO JOIN TWO FILES BASED ON A KEY
KNOW YOUR MAINFRAME
REXX – INITIAL SETUP
HOW TO SUBMIT A BATCH JOB FROM THE CICS PROGRAM
CICS – EXEC interface block – EIBRESP Values
CICS – EXEC interface block Fields
Flow of control between COBOL programs, run units, and CICS
CICS INTERVIEW QUESTIONS
CICS TIPS
COBOL – COPY and INCLUDE statements
COBOL – PERFORMANCE IMPROVEMENT
COBOL – SIGN STORED IN COMP, COMP-3 AND DISPLAY FORMATS
SHORTEST COBOL PROGRAM
RESTART LOGIC IN COBOL DB2 Program
GOBACK – EXIT PROGRAM – STOP RUN
Continuation lines in COBOL
Computational items – COMP, COMP 1 , COMP 2, COMP 3
COBOL program format
cobol indicator area column-7 and area a and area b
COBOL INTERVIEW QUESTIONS
COBOL TIPS
COBOL COMPILER OPTIONS
The IDENTIFICATION DIVISION