Page 1 of 1

How to split file by multiple dup recs into multiple files.

Posted: Fri Jan 27, 2012 2:33 am
by scramblermike
hello,
I have researched the forums and the manuals. i think i am trying to take Sort /SPLIT to far, but wanted to find out if this is possible.

I have a 100,000 rec file (volume always changes) that is sorted in keyed order by first 50 bytes, There is always multiple duplicate key records. I want to SPLIT the file into 4 some what equal output data sets with the duplicate keys on the same output date set, before writing to the next data set. Since the key values always change, i cant code them in sort. The number of duplicate records is variable also.

The idea would be each time key changes write to the next data set revolving thru the 4 files.

The SPLIT functions doesn't seem to be able to do variable splits based on key.

Any suggestions would be very welcomed.

Thank you in advance,
scramblermike

Posted: Fri Jan 27, 2012 3:34 am
by Frank Yaeger
If I understand correctly what you want to do, you can use a DFSORT job like the following. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes. I also assumed your records were already in sorted order by the key (if not, use SORT and OUTREC instead of COPY and INREC).

Code: Select all

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//OUT1 DD DSN=...    outpuf file1 (FB/80)
//OUT2 DD DSN=...    outpuf file2 (FB/80)
//OUT3 DD DSN=...    outpuf file3 (FB/80)
//OUT4 DD DSN=...    outpuf file4 (FB/80)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,50),PUSH=(81:ID=8)),
    IFTHEN=(WHEN=INIT,OVERLAY=(89:81,8,ZD,MOD,+4,TO=ZD,LENGTH=8))
  OUTFIL FNAMES=OUT1,INCLUDE=(89,8,ZD,EQ,1),BUILD=(1,80)
  OUTFIL FNAMES=OUT2,INCLUDE=(89,8,ZD,EQ,2),BUILD=(1,80)
  OUTFIL FNAMES=OUT3,INCLUDE=(89,8,ZD,EQ,3),BUILD=(1,80)
  OUTFIL FNAMES=OUT4,INCLUDE=(89,8,ZD,EQ,0),BUILD=(1,80)
/*

Posted: Fri Jan 27, 2012 10:57 pm
by scramblermike
Thank you for you help with this. i see that i need to keep a more open mind when looking for the solution to the problem. i hadn't gone down the path you suggested. Mike

Posted: Sat Jan 28, 2012 7:07 pm
by tamilselvan.sampath
hi frank what is keybegin....i refered all manuals only begin is there......will you please tell me what is keybegin is group parse

Posted: Tue Jan 31, 2012 12:07 am
by Frank Yaeger
You can find details on DFSORT's KEYBEGIN function at:

http://www.ibm.com/support/docview.wss? ... g3T7000242

KEYBEGIN is also documented in "z/OS V1R12 DFSORT Application Programming Guide" at:

http://www.ibm.com/support/docview.wss? ... g3T7000242