Created On:  12 March 2012
Problem:
I created a Visual COBOL program that uses the following syntax:
where FILENAME is defined as:
01 FILENAME PIC X(30) VALUE "TESTFILE.DAT".
When performing the statement:
OPEN OUTPUT TEST-FILE
a file-status value of "35" is returned which means file does not exist.
This program worked fine under RM/COBOL.
What is causing this problem?
     SELECT OPTIONAL TEST-FILE
     ASSIGN TO DISC FILENAME
     ORGANIZATION IS LINE SEQUENTIAL
     FILE STATUS IS FILE-STATUS.
where FILENAME is defined as:
01 FILENAME PIC X(30) VALUE "TESTFILE.DAT".
When performing the statement:
OPEN OUTPUT TEST-FILE
a file-status value of "35" is returned which means file does not exist.
This program worked fine under RM/COBOL.
What is causing this problem?
Resolution:
The word "DISC" is not recognized by the Visual COBOL compiler.  According to the documentation for the File-Control entry the keyword should be "DISK" and not "DISC".
The compiler is interpreting the word "DISC" as being a data-item name that should contain the name of the file when it is opened. Since "DISC" does not exist in the working-storage section the compiler generates the data-item automatically.
When the following syntax is used in Visual COBOL:
SELECT OPTIONAL TEST-FILE ASSIGN TO DISC FILENAME
It should give a warning that FILENAME will be treated as documentary even though it is a valid data-item in working-storage because the compiler interprets this statement as having two data items in the assign clause which is allowed but the second item will be treated as documentary.
If you change "DISC" to "DISK" it works as expected.
You could also use the checker directive:
If you did not want to change your code.
The compiler is interpreting the word "DISC" as being a data-item name that should contain the name of the file when it is opened. Since "DISC" does not exist in the working-storage section the compiler generates the data-item automatically.
When the following syntax is used in Visual COBOL:
SELECT OPTIONAL TEST-FILE ASSIGN TO DISC FILENAME
It should give a warning that FILENAME will be treated as documentary even though it is a valid data-item in working-storage because the compiler interprets this statement as having two data items in the assign clause which is allowed but the second item will be treated as documentary.
If you change "DISC" to "DISK" it works as expected.
You could also use the checker directive:
addsyn"disk"="disc"If you did not want to change your code.
Old KB# 35633
        
