Microsoft KB Archive/42320

“Bad File Name” When Filename Is Passed in LINKAGE-SECTION

PSS ID Number: Q42320 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 a run-time error “004 Illegal file name” when a subprogram has been passed a filename through the LINKAGE-SECTION, which then attempts to be OPENed. 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.

Code Example
The two following program examples demonstrate the “Illegal file name” problem. The examples contain the necessary directives in the $SET statement. The following is the main COBOL program MAINCOB.CBL: $SET ans85 WORKING-STORAGE SECTION. 01 temp pic x(3). 01 DATA-FN PIC X(8) VALUE “DATA.DAT”. PROCEDURE DIVISION. display “here we go…” with blank screen. accept temp. CALL “PROBLEM” using DATA-FN. STOP RUN. The following is the COBOL subprogram PROBLEM.CBL: $SET ans85 FILE-CONTROL. SELECT MDAT ASSIGN DISK ORGANIZATION LINE SEQUENTIAL. DATA DIVISION. FILE SECTION. FD MDAT LABEL RECORDS STANDARD RECORD CONTAINS 28 CHARACTERS VALUE OF FILE-ID IS DATA-FN. 01 MDAT-REC. 05 MDAT-KEY PIC 9(3). 05 MDAT-NAME PIC X(25). WORKING-STORAGE SECTION. LINKAGE SECTION. 01 DATA-FN PIC X(8). PROCEDURE DIVISION USING DATA-FN. DISPLAY “::::::::::::::::::::::::::::::::::::::” AT LINE 21 COLUMN 19. DISPLAY DATA-FN AT LINE 21 COLUMN 19. OPEN INPUT MDAT. EXIT PROGRAM. Here is the DATA.DAT data file: 111This is the first record 222This is the secnd record 333This is the third record The following two programs demonstrate a method to work around this problem. The main program passes a file number through the LINKAGE SECTION, which the subprogram in turn OPENs with the corresponding filename. The following is the new main COBOL program MAIN.CBL: $SET ANS85 WORKING-STORAGE SECTION. 01 temp pic x(3). 01 FILE-NUM PIC 9 VALUE 1. PROCEDURE DIVISION. display “here we go…” with blank screen. accept temp. call “NOPROB” using FILE-NUM. STOP RUN. The following is the new COBOL subprogram NOPROB.CBL: $SET ANS85 FILE-CONTROL. SELECT MDAT ASSIGN DISK ORGANIZATION LINE SEQUENTIAL. DATA DIVISION. FILE SECTION. FD MDAT LABEL RECORDS STANDARD RECORD CONTAINS 28 CHARACTERS VALUE OF FILE-ID IS DATA-FN. 01 MDAT-REC. 05 MDAT-KEY PIC 9(3). 05 MDAT-NAME PIC X(25). WORKING-STORAGE SECTION. 01 DATA-FN PIC X(8). LINKAGE SECTION. 01 FILE-NUM PIC 9. PROCEDURE DIVISION USING FILE-NUM. IF (FILE-NUM = 1) THEN MOVE “DATA.DAT” TO DATA-FN. DISPLAY “::::::::::::::::::::::::::::::::::::::” AT LINE 21 COLUMN 19. DISPLAY DATA-FN AT LINE 21 COLUMN 19. OPEN INPUT MDAT. EXIT PROGRAM.

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