As suggested, simply define four output files, open them, and then write to them based on the data in the input file record, perhaps using an EVALUATE statement. Opening them all at the start of your program has another advantage: if you open only one output at a time and loop between them, it's possible that another job could open your target file when you have it closed and you will not be able to get ahold to write to it.
If you really must have only one output file open at a time, you can dynamically allocate and deallocate the DDNAME amongst multiple DSNs with BPXWDYN; ostensibly an OMVS routine designed for use with REXX, but I have used it with COBOL as well. call BPXWDYN using "alloc fi(ddanme) da(my.dataset.name) old" *> change the DISP as required call BPXWDYN using "free fi(ddanme)" ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN