Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
I have never heard of sample code for such a requirement -- so basically you are asking for us to give you the code. This is a HELP forum, not a WRITE-THE-CODE-FOR-YOU forum. If / when you have specific questions about specific problems, post them and we will (usually) be able to help.
Questions I would be asking:
1. Are the files sorted by I1 already?
2. What are the I1, I2, ... ? Are they separate records (and if so, how are records identified?)? If not, does every record have the same data (that is, does every record of file A have I1, I2, I3, I4, I5, I6 in sequence or can one -- or more -- of them be missing)?
3. What are the record lengths for file A, file B, and the output file?
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
It sounds like you need to sit down and work through what to do -- create some test records for file A and file B (with matches on I1 and non-matches on I1), and manually use pen and paper to walk through what should happen. This can be a VASTLY helpful exercise as it gives you a feel for what the logic needs to be. Things to be resolved:
- what if an I1 in file A does not have a match in file B?
- what if an I1 in file B does not have a match in file A (usually the same thing but sometimes not)?
- how long will the output record be?
- how many records in file A and B? How many output records do you expect from those records?
Many programmers tend to start coding way too early, before they fully understand the data to be processed. When this happens, they either have to scrap some of what they've written and write correct code (which often they don't want to do after investing the time in the code), or (FAR more frequently) they attempt to shoehorn the written code into the needed process, causing continuing issues since the code doesn't really fit the data.