Phuong Le
Phuong Le

Reputation: 11

Why does Open File statement return error status '95'?

I defined the file CLNTPF as below:

A          R CLNTREC                                         
A            CLNTID         5S 0       COLHDG('CLIENT ID')   
A            CLNTNAME     200A         COLHDG('CLIENT NAME') 
A          K CLNTID      

                                

Then, I write the COBOL to open and read it.

INPUT-OUTPUT SECTION.                               
                                                    
FILE-CONTROL.                                       
     SELECT INF-CLNTPF ASSIGN TO DATABASE-CLNTPF    
     ORGANIZATION IS INDEXED                        
     ACCESS MODE IS SEQUENTIAL                      
     RECORD KEY IS CLNTID                           
     FILE STATUS IS WS-CLNTPF-FS. 

FILE SECTION.                                                           
FD  INF-CLNTPF.                     
01  REC-CLNTPF.                     
    COPY DDS-ALL-FORMATS OF CLNTPF. 

PROCEDURE DIVISION.
A100-INIT.                                         
    OPEN INPUT   INF-CLNTPF.                                                                            
    DISPLAY 'OPEN FILE STATUS IS ' WS-CLNTPF-FS.   
    READ INF-CLNTPF INTO REC-CLNTPF                
    AT END                                         
       DISPLAY 'END OF FILE'                       
    END-READ.                                      
    DISPLAY 'READ FILE STATUS IS ' WS-CLNTPF-FS.  

Result is :

OPEN FILE STATUS IS 95

READ FILE STATUS IS 00


Do you know why Open statement was returned error status '95' ? How to fix it ? Thank for your ideas.

Upvotes: 1

Views: 1422

Answers (1)

nfgl
nfgl

Reputation: 3202

If the source for CLNTPF is complete (no UNIQUE keyword), then you can find description of the error here.

High order digit = 9 means Other errors Low order digit = 5 reads

Invalid or incomplete file information (1) Duplicate keys specified in COBOL program. The file has been successfully opened, but indexed database file created with unique key; or (2) Duplicate keys not specified in COBOL program, and indexed database file created allowing duplicate keys.

So adding a UNIQUE keyword to your DDS source, and/or using EXTERNALLY-DESCRIBED-KEY / adding WITH DUPLICATES to the RECORD KEY clause would be the solution.

Upvotes: 2

Related Questions