Page 1 of 1

Cobol File return status 04

PostPosted: Fri Feb 17, 2012 10:18 pm
by Nara_513
Hi All...


I have written COBOL program where i am trying to read a VSAM file....
The file decalration is as follows:

SELECT INACTIVE-MASTER ASSIGN TO VSAM1

ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS APP-REC-KEY OF INACTIVE-MASTER-RECORD
FILE STATUS IS FILE-STATUS-CODE.


FD INACTIVE-MASTER
RECORD IS VARYING.
01 INACTIVE-MASTER-RECORD.
COPY BOOK.
EJECT



In procedure division i tried to read the file using teh command:
READ INACTIVE-MASTER NEXT
IF SUCCESSFUL-IO
...
mY logic will run
ELSE
Dispaly file status
Abend routine


when run the prog, i am getting the below error:

STATUS-CODE: 04


Since 04 indicates:

A READ statement was successfully executed, but the length of the
record being processed did not conform to the fixed file attributes
for that file.

I couldnt able to figure out where i went wrong...

can u pls help me out...

Re: Cobol File return status 04

PostPosted: Fri Feb 17, 2012 10:34 pm
by Robert Sample
The message is pretty clear. You read a record from the VSAM file, and the length of the record in the VSAM file did not match the length your COBOL program said the recrod would be. Possibilities (these are not the only ones, but the most likely ones):

1. The record length is fixed in the VSAM file, fixed in the COBOL progam, but the two lengths are different.
2. The record length is variable in the VSAM file, fixed in the COBOL program, but the length of the VSAM record did not match the length of the FD 01 in the COBOL program.
3. The record length is variable in the VSAM file, variable in the COBOL program, but the length of the VSAM record is smaller than the smallest FD 01 (or larger than the largest FD 01) in the COBOL program.
4. The record length is variable in the VSAM file, variable in the COBOL program with no OCCURS DEPENDING ON clause and the length of the VSAM record did not match the length of ANY FD 01 in the COBOL program.

Have you done a LISTCAT on the VSAM file? Have you compared the LISTCAT output to your COBOL program definition for that VSAM file?

Re: Cobol File return status 04

PostPosted: Sat Feb 18, 2012 12:51 pm
by Anuj Dhawan
And a short question - how did you create the input VSAM file? Showing a LISTCAT, as Robert asks for, or the IDCAMS DEFINE might help further.

Re: Cobol File return status 04

PostPosted: Sun Feb 19, 2012 12:47 pm
by Nara_513
Hi Robert,


As you mentioned i have checked the VSAm file size it is actually 5000, then i checked my copy book size it is 4890.

So i converted my personal VSAm to size 4890 using the file aid option and reran the jcl:

After this when i run , i got the same error:

U100-READ-MATER-FILE-ERR: VSAM1
STATUS-CODE: 04


I am taking a copy of Original file to my perosnal dataset.
The default values for

Original file:


Organization: KSDS EXT-ADDR COMP
KSDS key length: 15
KSDS key location: 0
Average record size: 3890
Maximum record size: 5000
Allocated Space: Unit Primary Secondary
Data: CYLINDERS 552 199
Index: TRACKS 47 17


Personal dataset that i am using in the JCl. after modifying:

Device type: 3390
Organization: KSDS
KSDS key length: 15
KSDS key location: 0
Average record size: 3890
Maximum record size: 4890
Allocated Space: Unit Primary Secondary
Data: CYLINDERS 552 199
Index: TRACKS 47 17


Now both the VSAm record lenght and the file record lenght in COBOL program are same...how come the job is failing with the same error...?

Re: Cobol File return status 04

PostPosted: Sun Feb 19, 2012 4:23 pm
by BillyBoyo
Can you show all the 01-levels associated with your FD, please? Expanded from any copybooks. If you don't have multiple 01's, that's probably the problem. The compiler needs to know maxium and minimum record-lengths. If you are not explicit (with from and to values or depending on) then the compiler takes for the different 01s. If you don't have different 01's, you have a fixed file, even having specified VARYING (as the compiler has nothing to determine how to vary). You fixed-length will then mismatch on the read.

Re: Cobol File return status 04

PostPosted: Sun Feb 19, 2012 7:25 pm
by Robert Sample
IF this is a typo:
Average record size: 3890
Maximum record size: 4890
then you need to learn how to use cut / paste on this forum. If this is NOT a typo, then your VSAM file is variable length, not fixed length, and your COBOL program must be changed to allow for a variable length VSAM file -- which means either using OCCURS DEPENDING ON or having multiple 01 record descriptions in your program under the FD for the VSAM file, with different record lengths, to indicate the variable length file.

Re: Cobol File return status 04

PostPosted: Mon Feb 20, 2012 10:45 am
by Nara_513
Thanks for all...who helped me out in solving this..

Hi Robert,

Thats not typo..my VSAM file is of variable lenth...

As u suggested i have used ' OCCURS DEPENDING ON" in my file section :

FD INACTIVE-MASTER
RECORD IS VARYING IN SIZE FROM 3890 TO 5000
DEPENDING ON REPORT-SIZE.
01 INACTIVE-MASTER-RECORD.

Which solved my problem.

Before that ... i just tried to get the lenghth of the first record..in the file which i am reading..i was shocked....the file record length is 1000...when i checked in the file...an empty line is found ...which is not dispalyed when i opened with a copy book.

So i deleted that empty file and reran the cobol prog and it got executed.

But one last question i have...how come am empty record length is displayed as 1000...y not the value between min length and max length...?

Re: Cobol File return status 04

PostPosted: Mon Feb 20, 2012 12:56 pm
by BillyBoyo
You have not used OCCURS DEPENDING ON in the code you have shown. ODO is not part of the FD. VARYING DEPENDING ON is. Check both in the manuals and understand thoroughly. Do some tests to confirm. VDO and ODO are different ways you could have chosen to solve the problem, as would have been supplying 01-levels of different sizes representing the different record-types on your file.

I can't make sense of what you say at the end. If the input file was empty, you'd get end-of-file (file-status 10). If the file was not empty, there'd be the length of the current record. If you feel you have something different, you have to fully describe why you think that and show the inputs/outputs which indicate that.