Microsoft KB Archive/40321

Multiple Print Jobs with SHARE Loaded Gives COBOL Error 027

PSS ID Number: Q40321 Article last modified on 04-20-1993

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

Summary: Microsoft COBOL versions 3.0 and 3.0a produce run-time error 027 “Device not available” under the following conditions: 1. The MS-DOS SHARE.EXE utility has been loaded into memory. 2. The COBOL program opens, prints, and closes a file assigned to PRINTER more than once. The sample program below produces run-time error 027 when run on a machine that has SHARE.EXE loaded into memory. This error does not occur if the COBOL program performs only one print job per run or the SHARE.EXE utility is not loaded into memory. It has been reported that increasing the number of file handles in the FILES=nn statement in the CONFIG.SYS file allows printing more jobs per run before you get the same error. To work around this problem, assign PRINTER files to DISK and print the files after exiting the COBOL program. Microsoft has confirmed this to be a problem in versions 3.0 and 3.0a. This problem was corrected in Microsoft COBOL Professional Development System version 4.0 for MS-DOS and MS OS/2.

More Information: The following sample program should be compiled and LINKed, accepting the default directives: FILE-CONTROL. SELECT PRINT-FILE ASSIGN TO PRINTER. DATA DIVISION. FILE SECTION. FD PRINT-FILE LABEL RECORDS OMITTED. 01 PRINT-REC PIC X(80). WORKING-STORAGE SECTION. 01 DUMMY PIC X(40). PROCEDURE DIVISION. OPEN OUTPUT PRINT-FILE. MOVE “tHIS IS THE LINE” TO DUMMY. PERFORM 25 TIMES WRITE PRINT-REC FROM DUMMY. CLOSE PRINT-FILE. OPEN OUTPUT PRINT-FILE. MOVE “THIS IS THE VERY FINAL” TO DUMMY. WRITE PRINT-REC FROM DUMMY AFTER PAGE. PERFORM 25 TIMES WRITE PRINT-REC FROM DUMMY. CLOSE PRINT-FILE. STOP RUN.

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.