1. Sort and split 'IN' file into the two output files as shown.
2. Write the existing header to each of the two output files.
3. Plug a fixed value of 'ABC' into the header of OT1.
4. Plug a fixed value of 'XYZ' into the header of OT2.
Joined: 09 Mar 2011 Posts: 7310 Location: Inside the Matrix
Sorry John, just found this in the HomeWork part of the forum, which isn't somewhere questions appear from (I thought it had been deleted after my answer).
If you want the output sorted and in the original order, you will have to do it in separate operations, as you have done already. OUTFIL (or after OUTREC, if no OUTFIL present) is where data is written, and the input is long gone by that point.
The one thing you could try is to use an E15 exit, which can be written in COBOL. You will be presented with each record from the input, which you can then format and write to new files, from the COBOL program. Whether you data and the number of files you require means that this will use fewer resources is going to be down to experimentation.