I am running one COBOL pgm which is reading one VSAM file. Below is ithe input output section in my pgm.
FILE-CONTROL.
SELECT INPUT-FILE ASSIGN TO DDINPUT
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS INPUT-KEY
FILE STATUS IS WS-INPUT-STATUS.
and FD entry is as follow.
FILE SECTION.
FD INPUT-FILE IS EXTERNAL (as this is in sub pgm)
COPY INPUTREC.
When I ran this pgm, it failed with file status code =04. Somewhere I found that when in FD we have only one record even if the file is VB it treats it is FB. So FB should have record contains or Varying clause.
When I updated my FD to.
FILE SECTION.
FD INPUT-FILE IS EXTERNAL
RECORD VARYING IN SIZE FROM 1 TO 215.
COPY INPLAYOUT.
job ran fine.
I have one doubt Can I specify this Varying clause to maximum length, like if I write this as eg RECORD VARYING IN SIZE FROM 1 TO 2500. then will it cause any issue?
Assuming your VSAM file is properly initialized and your JCL is coded consistently with your program requirements there should be no issue.
The VARYING clause is simply telling COBOL to reserve enough space in the buffer for the maximum expected record size and indicates that the file contains records that are expected to vary in size from one I/O call to the next. If it had been FB (Fixed Block), COBOL expects the record to be a constant size and will trigger the status code 04 if the record deviates from the expected size. For VB (Variable Block) a return code 04 could still occur if your record size exceeds the maximum VARYING defined limit.
Personally I find COBOL I/O Status conditions somewhat cryptic to understand.
Here is a table of ANSI COBOL I/O Status Codes that I keep handy for file i/o debugging purposes:
0x - Successful Completion
00 - No futher information
02 - Duplicate Key detected
04 - Wrong Length Record
05 - File created when opened. With sequential VSAM 00 is returned.
07 - CLOSE with NO REWIND or REEL for non-tape dataset.
1x - End of File conditions
10 - No futher information
14 - Relative record READ outside boundry.
2x - Invalid Key condition
21 - Sequence Error
22 - Duplicate Key
23 - No Record found
24 - Key outside boundry
3x - Permanent I/O Errors
30 - No further information
34 - Record outside file boundry
35 - OPEN and required file not found.
37 - OPEN with invalid mode
38 - OPEN of file closed with a LOCK
39 - OPEN unsuccessful due to conflicting file attributes
4x - Logic Errors
41 - OPEN of file already open
42 - CLOSE of file not open
43 - READ not executed before REWRITE
44 - REWRITE of different size record
46 - READ after EOF reached
47 - READ attempted for file not opened I-O or EXTEND
48 - WRITE for file not opened OUTPUT, I-O, or EXTEND
49 - DELETE or REWRITE for file not opened I-O
9x - Specific Compiler defined exceptions
90 - No further information
91 - VSAM Password failure
92 - Logic Error
93 - VSAM Resource unavailable
94 - VSAM Sequence record not available
95 - VSAM invalid or incomplete file information
96 - VSAM no DD statement
97 - VSAM OPEN successful, file integrity verified.