elmister
New User
Joined: 27 Nov 2005 Posts: 14
|
|
|
|
Hi, I need to do the following:
I have a input file like this:
000001
000001
000001
000002
000002
000003
000004
000004
000005
000005
000005
000005
000006
I want this information splited in three files, but without the split the records with the same key, like following:
output file 1:
000001
000001
000001
000004
000004
output file 2:
000002
000002
000005
000005
000005
000005
output file 3:
000003
000006
So I want all the records with the same key in the same output file, not one record with key 000001 in the output file1, output file2, etc.. |
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Below sortstep will give you desired result.
I have assumed LRECL=80,RECFM=FB.
Do the changes accordingly if required.
Code: |
//S1 EXEC PGM=SORT
//SORTIN DD *
000001
000001
000001
000002
000002
000003
000004
000004
000005
000005
000005
000005
000006
//SORTOF1 DD SYSOUT=*
//SORTOF2 DD SYSOUT=*
//SORTOF3 DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,6,CH,A)
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,6))),
IFTHEN=(WHEN=GROUP,BEGIN=(81,8,ZD,EQ,1),PUSH=(89:ID=8)),
IFTHEN=(WHEN=NONE,OVERLAY=(97:89,8,ZD,MOD,+3,ZD,LENGTH=1))
OUTFIL FNAMES=SORTOF1,INCLUDE=(97,1,ZD,EQ,1),BUILD=(1,80)
OUTFIL FNAMES=SORTOF2,INCLUDE=(97,1,ZD,EQ,2),BUILD=(1,80)
OUTFIL FNAMES=SORTOF3,SAVE,BUILD=(1,80)
/*
|
|
|