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

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
scramblermike
Member
Posts: 2
Joined: Fri Jan 27, 2012 2:01 am

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

Post by scramblermike » Fri Jan 27, 2012 2:33 am

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

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Jan 27, 2012 3:34 am

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)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

scramblermike
Member
Posts: 2
Joined: Fri Jan 27, 2012 2:01 am

Post by scramblermike » Fri Jan 27, 2012 10:57 pm

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

tamilselvan.sampath
Member
Posts: 26
Joined: Mon Jan 23, 2012 11:17 pm

Post by tamilselvan.sampath » Sat Jan 28, 2012 7:07 pm

hi frank what is keybegin....i refered all manuals only begin is there......will you please tell me what is keybegin is group parse

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Jan 31, 2012 12:07 am

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
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others