Page 1 of 1

'RECORDING V' file problem

PostPosted: Mon Feb 14, 2011 1:10 pm
by ElHachu
Hi all,

I'm testing an Enterprise Cobol program with an variable length input file. Its register is defined in File Section as PIC X(3600), and the file has physical lrec of 3604.

When I submit the job I obtain a file status 4 (error with the lrec).

I think you should know this program was written and compiled as Cobol, but now the client is migrating to Enterprise Cobol. Can this be the problem?

I post the FD

FD MYFILE RECORDING V
LABEL RECORD STANDARD
BLOCK CONTAINS 0 RECORDS.
01 REG-MYFILE PIC X(3600).

These are the file attributes: Dsorg=PS Recfm=VB Lrecl=3604


Thank you in advance for all your time and help.

Re: 'RECORDING V' file problem

PostPosted: Mon Feb 14, 2011 3:47 pm
by Robert Sample
A file status 04 does not mean you have a problem with the LRECL. A file status 04 means you attempted to read a record (which worked) but you do not have any 01 under the FD that has the length of the record just read. There is something (record type variable or occurrences / length variable) that tells how long each of the variable length records is. If it is a record type, you need one 01 for each record type with the length of that record type. If it is an occurrences / length indicator, you need to change your FILLER PIC X(3600) to describe the record at least through the OCCURS DEPENDING ON clause so the 01 is not a fixed length record (which you have defined it to be).

Re: 'RECORDING V' file problem

PostPosted: Mon Feb 14, 2011 4:02 pm
by ElHachu
Thank you for your answer Robert.

I think it may be the first option you say (occurrences / length indicator).

When I read the file, I read it into a 01 level with 57 positions (in lower levels). I don't know why we use a 3604 lrec file, but it is not in my hand to change this and many processes would be affected.

Do you think that if I add a filler until completing the 3604 positions it would work?

Thank you again.

Re: 'RECORDING V' file problem

PostPosted: Mon Feb 14, 2011 4:09 pm
by ElHachu
Robert, I think I found the solution. Excuse me, YOU found the solucion. You were right. Thank you so much.

Re: 'RECORDING V' file problem

PostPosted: Mon Feb 14, 2011 5:42 pm
by Robert Sample
The 3604 is because a variable length file requires a way to identify how long each record is. IBM determined, many many many years ago, to use a 4-byte prefix on each record. The first two bytes of the prefix have the record length and the second two bytes are reserved. Hence if your COBOL program has a maximum length of 3600 for a variable length record, the LRECL will be 3604. The block size must be at least 3608 (there's a 4-byte block length prefix for each block since the block length needs to be kept somewhere, too).