Microsoft KB Archive/35144

From BetaArchive Wiki

“File Not Found” if Variable Filename More Than 12 Characters

PSS ID Number: Q35144 Article last modified on 04-21-1993

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

The information in this article applies to:
- Microsoft COBOL for MS-DOS and OS/2, versions 3.0 and 3.0a

Summary: Under Microsoft COBOL Versions 2.x, a filename initialized in a variable in the DATA DIVISION can be as long as required. Under COBOL Versions 3.0 and 3.0a, a filename may still be declared in the DATA DIVISION; however, unless it is also explicitly declared in the WORKING-STORAGE SECTION, it can only be a maximum of 12 characters long. If you use more than 12 characters, no error message occurs at compile time, but the error 013 “File Not Found” will display at run time. The following code example shows the correct method for using filenames longer than 12 characters. This syntax is required for specifying paths to data files across disk directories or drives. The “Microsoft COBOL Version 3.0: Language Reference Manual,” Page 5-24 (under the ENVIRONMENT DIVISION), explains that in the phrase “SELECT IN-FILE ASSIGN TO…” the length of IN-FILE defaults to 12 characters unless explicitly declared within the program.

More Information: Note that the above requirement should also be added in the DATA DIVISION discussion in “Microsoft COBOL Version 3.0: Language Reference Manual.” The following is a code example: ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT IN-FILE ASSIGN TO DISK ORGANIZATION IS LINE SEQUENTIAL. DATA DIVISION. FILE SECTION. FD IN-FILE LABEL RECORDS ARE STANDARD VALUE OF FILE-ID IS FILE-NAME DATA RECORD IS INPUT-RECORD. 01 INPUT-RECORD PIC X(80). WORKING-STORAGE SECTION. 01 The-Rec. 05 Card PIC x(5). 05 Lift PIC x(9). 05 Fly PIC x(2). 01 FILE-NAME PIC x(14) VALUE “a:.dat”. PROCEDURE DIVISION. OPEN INPUT IN-FILE. CLOSE IN-FILE. STOP RUN.

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