Posted: Mon Aug 20, 2007 7:02 am Post subject: Split header and trailer file into several files.
I have a file with header and trailer records.
The header records always starts with 1 in postion 1 and trailer records with 2 in position 2. The file is FB with LRECL=68.
Example of a file with header and trailer records.
Code:
1Header1 xxxxxxxxxxxxxxxxxxx x
2aaaaa bbbbbb X
2bbbbb 20030401 S
2........ .... .
1Header2 xxxxxxxxxxxxxxxxxxx x
2aaaaa bbbbbb X
2bbbbb 20030401 S
2gggggggg 0 S
2........ .... .
and so on.
The file will have a about a million records. I want to split this file into 10 files.
The first 10,000 header records(with 1 in postion 1) and the corresponding trailer records(with 2 in position 2)
should be in the first file and the next 10,000 header records(with 1 in postion 1) and the corresponding trailer records(with 2 in position 2) should be in the second file and so on and the last bit which could be less than 10,000 in the last file.
I have seen the split files examples on this board. In my case I have to make sure that the header records has all it's trailer records in the same file.
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Mon Aug 20, 2007 7:18 am Post subject:
Quote:
The header records always starts with 1 in postion 1 and trailer records with 2 in position 2.
Shuko,
The sample data you have shown does not match the description. I see that the detail records also have a '2' in the first position. Also when you say you want extract header and trailer , do you mean you just want the header and trailer without the detail records like shown below?
Sorry my mistake. By trailer I actually wanted to say detail records.
so the first output file should have the following output,10,000 times header record with the detail records and the next file with the next 10,000 and so on.
The first output file
Code:
1Header1 xxxxxxxxxxxxxxxxxxx x
2aaaaa bbbbbb X
2bbbbb 20030401 S
2........ .... .
1Header2 xxxxxxxxxxxxxxxxxxx x
2aaaaa bbbbbb X
2bbbbb 20030401 S
2gggggggg 0 S
2........ .... .
and so on till 10,000 times header with the detail records
Thank you Kolusu. The JCL worked as expected.
I was just wondering, if it is possible to averagely divide the input file into 10 files, since I won't know the exact size of the file in advance.
Suppose I have 175,000 times, Header records with trailer records in the input file. Split this into 10 files and write 17,500 in each file. Is this possible?
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Tue Aug 21, 2007 7:19 am Post subject:
shuko,
is it really hard that hard to describe your problem in one go? The dynamic split has been discussed many times in this forum. Please SEARCH before posting. Check this topic.
I seem to have a problem now with splitting header and detail records into several files. I am trying to split a file with several million records.
with this code. I am splitting the source file into 5 files of 500,000 each.
This 500,000 is the header with the detail records. I had a problem only in the fifth file. The first few records in the fifth file had the header and the detail records and then the following records had only the header record without the detail records. This happened
only in the last file. What am I doing wrong here?. For smaller files, this code works well.
I am splitting the source file into 5 files of 500,000 each.
Y are there output files till OUT06 when you are splitting the input file to 5 output files? _________________ Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
The first few records in the fifth file had the header and the detail records and then the following records had only the header record without the detail records. This happened
Can you post the total number or records in the input file? _________________ Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
You can get the count of the records using TALLY option in Fileaid.
In the file aid menu, go to "Interactive option" and then issue the command TALLY command. _________________ Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Oct 26, 2007 11:41 am Post subject:
Quote:
I had a problem only in the fifth file. The first few records in the fifth file had the header and the detail records and then the following records had only the header record without the detail records.
I can't see any obvious reason why that would happen unless those last groups of records only had a header record without detail records. The job assigns a sequence number to each group of header and detail records and then you select those groups by their sequence number. So there's nothing different about the way the OUTFIL for OUT06 works vs the other OUTFILs. The difference might be in the input file. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Frank
This was my first reaction, regarding the input file. The input file had the header and detail records. Since the last file was corrupted, I had to manually locate the record position in the source file and use SKIPREC to copy the records for the last file. The file copied had both the header and
detail records. My tests show that, copying 500,000 header and detail records (average of 45 detail records for every header record) in four files works as expected but the fifth file does not. After a few 100 header-detail records, only the header gets copied.
I tried with a smaller file of 73840416 records. This produced 2 files with
500,000 header-detail records and the 3rd file with 488197 header-detail
records. I had both the header and detail records in the last file.
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