Posted: Tue Jan 12, 2016 6:23 pm Post subject: Split file into two based on occurrence of another field
I have a requirement to split an input file into two. The input file has millions of records pertaining to different account numbers. My system has a maximum of 20,000 account numbers. At any given time I will be expecting less than 20,000 of account related data present in the file I mentioned above. Each account can have multiple records present in the input file. I want to split the file when I encounter 10,000th account (and it's related records) and put it into one file and the remaining records should be kept into the second file. Here is the sample file. LRECL is 80, FB. Account number starts at 72nd position and it’s 9 byte length.
WHEN=GROUP has an option to mark each record within a group with a group-number (you PUSH an ID). Append that to each record (assuming fixed-length records, prepend with variable-length records).
Use OUTFIL INCLUDE=/OMIT= to only select records with an ID less-than-or-equal-to 10000. Use BUILD there to return records to their original size.
Use a second OUTFIL with SAVE to output all the records which don't already appear on an OUTFIL. Again use BUILD to return the records to their original size.
Thanks Kolusu and Williams. Much appreciated your response. I have tried with the above control card (which Kolusu provided) to test the following data to obtain two account numbers and related data
in the first file and rest in second. Modified the control card to LE,2 in INCLUDE condition.
All I've done is changed a comma to a blank, so that the BUILDs become comments. You can then see the values that have been PUSHed.
Edit: What I suspect is that you have your test-data in a numbered PDS/PDSE member with RECFM 80, so what you think is your key is actually an ISPF sequence number.
Last edited by William Collins on Wed Jan 13, 2016 12:14 pm; edited 1 time in total
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Wed Jan 13, 2016 12:13 pm Post subject:
somuk,
Is your Input file FB file or a VB file? and are you sure that the account number starts at 72 for 9 bytes?
There is a quick way to check it. Assuming your Input hass FB RECFM and the account number does start at position 72, use the following control cards to display the account number and the counter
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Wed Jan 13, 2016 12:16 pm Post subject:
William Collins wrote:
Edit: What I suspect is that you have your test-data in a numbered PDS/PDSE member with RECFM 80, so what you think is your key is actually an ISPF sequence number.
William,
I was about to quote you that it is probably the line numbers that is messing up Somuk's test JCL. Like Minds think alike. _________________ Kolusu
www.linkedin.com/in/kolusu
Thanks William and Kolusu.
You are correct. My bad. Made a mistake when I tried with the SYSIN instream data. Thanks a lot for your help. _________________ Regds,
Somu
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum