Page 1 of 2

FILE STATUS CODE IS :37

PostPosted: Wed Mar 30, 2016 3:48 pm
by CobDummy
Hi,

I am beginner in mainframe
Could someone please guide me, I am getting status code 37 error.

[B]Cobol Code[B]
IDENTIFICATION DIVISION.        
 PROGRAM-ID. EMPINDX.            
 ENVIRONMENT DIVISION.          
 INPUT-OUTPUT SECTION.          
 FILE-CONTROL.                  
     SELECT EMP-INDEX            
     ASSIGN TO EMPINDEX          
     ORGANIZATION IS INDEXED    
     RECORD KEY IS EMP-ID        
     ACCESS MODE IS DYNAMIC      
     FILE STATUS IS WS-STATUS.  
                                 
 DATA DIVISION.                  
 FILE SECTION.                  
 FD  EMP-INDEX                  
     LABEL RECORDS ARE STANDARD.
 01  EMP-RECORD.                
     05 EMP-ID         PIC 9(5).
     05 EMP-FNAME      PIC X(10).
     05 EMP-LNAME      PIC X(10).
                                 
 WORKING-STORAGE SECTION.        
 01  WS-STATUS  PIC X(2).        
                                 
 PROCEDURE DIVISION.            
 PROGRAM-BEGIN.                  
     OPEN OUTPUT EMP-INDEX.            
     DISPLAY WS-STATUS.                
     PERFORM  WRITE-EMP.                
     CLOSE    EMP-INDEX.                
                                       
 PROGRAM-DONE.                          
     STOP RUN.                          
                                       
 WRITE-EMP.                            
     MOVE "100001"     TO     EMP-ID.  
     MOVE "EMP1"       TO     EMP-FNAME.
     MOVE "EMP1L"      TO     EMP-LNAME.
     WRITE   EMP-RECORD.                
     DISPLAY WS-STATUS.                


[b]JCL Code[b]
//G725590A JOB ,,NOTIFY=&SYSUID,CLASS=D,MSGLEVEL=(1,1),MSGCLASS=X
//JOBLIB DD DSN=OPERN.COBOL.LOADLIB,DISP=SHR                    
//STEP1 EXEC PGM=EMPINDX                                        
//EMPINDEX DD DSN=G725590.TSO.TEST.MYDATA,DISP=SHR              


[b]Cluster[b]
DEFINE CLUSTER (NAME(G725590.TSO.TEST.MYDATA) -
VOLUMES(VSER02) -              
RECORDS(100 50) -            
) -                              
DATA (NAME(G725590.TSO.TEST.KSDATA) -  
  KEYS(5 1) -                      
  RECORDSIZE(25 25) -              
   BUFFERSPACE(250) -              
   )-                                  
INDEX (NAME(G725590.TSO.TEST.KSINDEX)-  
 )

Re: FILE STATUS CODE IS :37

PostPosted: Wed Mar 30, 2016 4:27 pm
by NicC
Have you looked up a file status of 37 in the manuals - or searched the internet for the reason?

Re: FILE STATUS CODE IS :37

PostPosted: Wed Mar 30, 2016 4:47 pm
by CobDummy
Hi.. yes i looked, but couldn't understand the reason..

File Status 37:
"An OPEN statement was attempted on a file that would not support the open mode specified in the OPEN statement. Possible violations are: 1. The EXTEND or OUTPUT phrase was specified but the file would not support write operations. 2. The I-O phrase was specified but the file would not support the input and output operations permitted. 3. The INPUT phrase was specified but the file would not support read operations."

Re: FILE STATUS CODE IS :37

PostPosted: Wed Mar 30, 2016 4:59 pm
by Robert Sample
VSAM data sets that are empty (that is, have never had a record in them) cannot be opened for INPUT or I-O until a record has been written to them.

Re: FILE STATUS CODE IS :37

PostPosted: Wed Mar 30, 2016 5:06 pm
by CobDummy
but this program opens file in output mode

Re: FILE STATUS CODE IS :37

PostPosted: Wed Mar 30, 2016 5:23 pm
by BillyBoyo
I suggest you look at the DEFINE. Specifically the KEYS. Check in your documentation.

Re: FILE STATUS CODE IS :37

PostPosted: Wed Mar 30, 2016 5:29 pm
by CobDummy
"[KEYS(length offset)]
Keys parameter is defined only in key-sequenced (KSDS) files. It specifies the length and offset of primary key from first column. The range of value of this parameter are from 1 to 255 bytes."
I am not sure whats wrong with KEYS(5 1)..

Re: FILE STATUS CODE IS :37

PostPosted: Wed Mar 30, 2016 5:59 pm
by Robert Sample
Offsets start at zero, positions at one. The first five bytes of your VSAM file are NOT the key as you have it defined.

Re: FILE STATUS CODE IS :37

PostPosted: Wed Mar 30, 2016 6:18 pm
by CobDummy
Thank you everyone, the offset was the problem, its working fine now. thank you. :)

Re: FILE STATUS CODE IS :37

PostPosted: Wed Mar 30, 2016 7:06 pm
by Terry Heinze
You might consider including function code and feedback code along with file status when dealing with VSAM files. More information. It's in the manual.