Joined: 18 Jul 2007 Posts: 2150 Location: At my coffee table
Why in COBOL?
Sort could do this in one simple pass....
An INREC to strip off headers and trailers followed by a sort (or merge if both files are in a key sequence) of the keys followed by a HEADER (because it is needed?) and TRAILER (to get the totals).
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
What you want to do is not a "merge" in the typical sense. A merge is a process that reads 2 (or more) files that are in sequence by some key(s) and generates output based on processing rules.
Are both files the same recfm and lrecl?
As CG mentioned, this could be done with your sort product. If you proceed with cobol, post pseudo code of how you want your code to process. We can help if there are design issues and later with the actual code if you have questions or problems.