If you need to print multiple jobs at the same time, you must open multiple File Descriptors that point to "-P SPOOLER" or "-P SPOOLER-DIRECT" simultaneously. For example, you may have two simultaneous print jobs:
SELECT FIRST-FILE ASSIGN TO PRINTER "-P SPOOLER". SELECT SECOND-FILE ASSIGN TO PRINTER "-P SPOOLER". ..PROCEDURE DIVISION. .. OPEN OUTPUT FIRST-FILE. OPEN OUTPUT SECOND-FILE.
and both will print to the default Windows printer without interfering with each other. You can call WIN$PRINTER USING WINPRINT-SETUP before one or both of the OPEN statements. Each file may have individual file status variables or may refer to a common file status variable.
This does not mean that you can open a single File Descriptor multiple times. For example, the following will return file status indicating that the file is already opened:
SELECT FIRST-FILE ASSIGN TO PRINTER "-P SPOOLER". .. PROCEDURE DIVISION. .. OPEN OUTPUT FIRST-FILE. OPEN OUTPUT FIRST-FILE.
This is normal behavior and is consistent with the way file handling is implemented in COBOL and in other programming languages.
If you are using only the verbs OPEN, CLOSE, and WRITE, no further changes to your code are needed. If you are using WIN$PRINTER functionality (other than WINPRINT-SETUP) you will need to specify which print job is affected. This can be done in two ways:
In this situation, if you have multiple jobs running, and you close one of them, the runtime switches to the next job in the list. For example, if you are printing jobs 1, 2, and 3, and you close job 2, the close command sets the current job to 3. If there is no job 3, the runtime attempts to set to the job that preceded the closed job (which in this case is job 1). If there are no jobs, the current job is initialized.