Cobol File return status 04



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Cobol File return status 04

Postby Nara_513 » Fri Feb 17, 2012 10:18 pm

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...
Nara_513
 
Posts: 44
Joined: Fri Dec 02, 2011 1:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: Cobol File return status 04

Postby Robert Sample » Fri Feb 17, 2012 10:34 pm

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?
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Cobol File return status 04

Postby Anuj Dhawan » Sat Feb 18, 2012 12:51 pm

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.
Anuj
Anuj Dhawan
 
Posts: 273
Joined: Mon Feb 25, 2008 3:53 am
Location: Mumbai, India
Has thanked: 6 times
Been thanked: 4 times

Re: Cobol File return status 04

Postby Nara_513 » Sun Feb 19, 2012 12:47 pm

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...?
Nara_513
 
Posts: 44
Joined: Fri Dec 02, 2011 1:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: Cobol File return status 04

Postby BillyBoyo » Sun Feb 19, 2012 4:23 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Cobol File return status 04

Postby Robert Sample » Sun Feb 19, 2012 7:25 pm

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.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Cobol File return status 04

Postby Nara_513 » Mon Feb 20, 2012 10:45 am

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...?
Nara_513
 
Posts: 44
Joined: Fri Dec 02, 2011 1:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: Cobol File return status 04

Postby BillyBoyo » Mon Feb 20, 2012 12:56 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post