ParagChouguley
Active User
Joined: 03 Feb 2007 Posts: 175 Location: PUNE(INDIA)
|
|
|
|
I have flat file which contains a base and addendum records. A byte on a record(at same position) identifies if its a base or addendum record (=0 means base, =1 means addendum) A base can have minimum zero and maximum 9 addendum records. No field on base record tells how many addendum records it carries. I want the file to be sorted on 5 fields which are present on base record. Needless to say that a base record and its corresponding addendum records must remain together.
I'm familiar with some of the sort tricks using sequence numbers. A logic of how to do this would be appriciated. ( as I assume, providing JCL without file is impossible)
Thanks in advance! |
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
paragchougley,
You haven't provided us with details, so I came up with the best guess as to how your data looks like and I assumed that your input is FB recfm and 80 byte LRECL. I assumed that you want to sort the 10 bytes on the base record starting from pos 3.
You can very easily push the contents of base records on to the addendum records the new WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
0 Z A Y C E
1 BLAH - GROUP 1 RECORD 1
1 BLAH - GROUP 1 RECORD 2
1 BLAH - GROUP 1 RECORD 3
1 BLAH - GROUP 1 RECORD 4
0 A C D F E
1 BLAH - GROUP 2 RECORD 1
1 BLAH - GROUP 2 RECORD 2
0 A C G H
1 BLAH - GROUP 3 RECORD 1
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION EQUALS
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,ZD,EQ,0),PUSH=(81:3,10,ID=8))
SORT FIELDS=(81,18,CH,A)
OUTFIL BUILD=(1,80)
/*
|
The output from this job is
Code: |
0 A C G H
1 BLAH - GROUP 3 RECORD 1
0 A C D F E
1 BLAH - GROUP 2 RECORD 1
1 BLAH - GROUP 2 RECORD 2
0 Z A Y C E
1 BLAH - GROUP 1 RECORD 1
1 BLAH - GROUP 1 RECORD 2
1 BLAH - GROUP 1 RECORD 3
1 BLAH - GROUP 1 RECORD 4
|
If you don't have the July, 2008 PTF installed, ask your System Programmer to install it (it's free).
For complete details on the new WHEN=GROUP and the other new functions available with PTF UK90013, see:
Use [URL] BBCode for External Links |
|