//Jobname JOB ,,REGION=0M,CLASS=E,MSGCLASS=Z,
// NOTIFY=&SYSUID
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1 FACETS 123456789
2 ACES 123456790
3 CHIPS 123456791
4 FACETS 123456792
5 CHIPS 123456793
6 CS90 123456794
7 NASCO 123456795
8 CHIPS 123456796
9 ACES 123456797
10 CS90 123456798
/*
//OUT01 DD SYSOUT=*
//OUT02 DD SYSOUT=*
//OUT03 DD SYSOUT=*
//OUT04 DD SYSOUT=*
//OUT05 DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(5,6,CH,A)
OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(5,6),PUSH=(21:ID=2))
OUTFIL FNAMES=OUT01,BUILD=(1,20),INCLUDE=(21,2,ZD,EQ,01)
OUTFIL FNAMES=OUT02,BUILD=(1,20),INCLUDE=(21,2,ZD,EQ,02)
OUTFIL FNAMES=OUT03,BUILD=(1,20),INCLUDE=(21,2,ZD,EQ,03)
OUTFIL FNAMES=OUT04,BUILD=(1,20),INCLUDE=(21,2,ZD,EQ,04)
OUTFIL FNAMES=OUT05,BUILD=(1,20),INCLUDE=(21,2,ZD,EQ,05)
/*
Output:
2 ACES 123456790 01
9 ACES 123456797 01
3 CHIPS 123456791 02
5 CHIPS 123456793 02
8 CHIPS 123456796 02
6 CS90 123456794 03
10 CS90 123456798 03
1 FACETS 123456789 04
4 FACETS 123456792 04
7 NASCO 123456795 05