View previous topic :: View next topic
|
Author |
Message |
JnanaR
New User
Joined: 20 Jul 2009 Posts: 23 Location: Mumbai
|
|
|
|
File status 04
I am reading a VB flat file.The lrecl is 5000. Below is my FD section
FD INPUT-DRIVER-FILE
LABEL RECORDS ARE STANDARD
RECORDING MODE IS V
BLOCK CONTAINS 0 RECORDS.
01 INPUT-DRIVER-REC PIC X(4996).
01 WS-INPUT-DRIVER-REC PIC X(4996).
READ INPUT-DRIVER-FILE INTO WS-INPUT-DRIVER-REC
I am getting file status 04 after the read statement.
Could anyone point out why I am getting file status as 04 instead of 00.
I googled file status 04 and it says
"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."
The explanation is not clear to me.Please help. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Change your code to the following -
Code: |
FD INPUT-DRIVER-FILE
LABEL RECORDS ARE STANDARD
RECORD CONTAINS XXXX TO 4996 CHARACTERS
DEPENDING ON WS-DRIVER-FILE-LGTH
RECORDING MODE IS V
BLOCK CONTAINS 0 RECORDS.
01 INPUT-DRIVER-REC PIC X(4996).
01 WS-INPUT-DRIVER-REC PIC X(4996).
WORKING-STORAGE SECTION.
01 WS-DRIVER-FILE-LGTH PIC 9(09) COMP.
|
Change the XXXX to the minimum length a given record can be.
Note that WS-DRIVER-FILE-LGTH must be UNSIGNED. I prefer fullword-binary (as illustrated), but you can also use PIC 9(05) COMP-3 or PIC 9(05). But remember, it must be UNSIGNED, regardless.
If you specify this field as SIGNED, you'll get compilation error.
After each READ, WS-DRIVER-FILE-LGTH will be set to the length of the record and the "04" should go away.
This feature was introduced with VS/COBOL II, in the mid/late 1980's.
Bill |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
your FD defines a fixed length record for a variable length file.
this has been discussed before,
spend some time and use the search facility.
or simply go thru the COBOL forum thread list.
especially since
Quote: |
"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." |
since that did not bother to get you thinking. |
|
Back to top |
|
|
JnanaR
New User
Joined: 20 Jul 2009 Posts: 23 Location: Mumbai
|
|
|
|
Thanks Bill for the help.I coded like this
FD INPUT-DRIVER-FILE
LABEL RECORDS ARE STANDARD
RECORDING MODE IS V
RECORD CONTAINS 1 TO 4996 CHARACTERS DEPENDING ON WS-DR-LEN
BLOCK CONTAINS 0 RECORDS.
01 INPUT-DRIVER-REC PIC X(4996).
But I got compliation errors mentioned below.
THE FIRST INTEGER OF THE "RECORD CONTAINS" CLAUSE FOR FILE "INPUT-DRIVER-FILE" WAS DIFFERENT FROM THE MINIMUM
CALCULATED RECORD SIZE 4996. 4996 WAS ASSUMED AS THE FIRST INTEGER.
"DEPENDING" WAS INVALID.SCANNING WAS RESUMED AT THE NEXT AREA "A" ITEM, LEVEL-NUMBER, OR THE START OF THE NEXT CLAUSE.
I think since I have defined
01 INPUT-DRIVER-REC PIC X(4996).
It's taking minimum calculated records size as 4996
How do I rectify these errors? |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
What version/release of COBOL are you using? Is it OS/VS COBOL, the predecessor to VS/COBOL II?
It's been quite a while and I've slept since then....
Bill |
|
Back to top |
|
|
JnanaR
New User
Joined: 20 Jul 2009 Posts: 23 Location: Mumbai
|
|
|
|
I think it's COBOL 3.I am not sure.. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
The COBOL version/release should be printed on each page of the compilation listing. Can you post this exact value?
Bill |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you remove the:
RECORD CONTAINS 1 TO 4996 CHARACTERS DEPENDING ON WS-DR-LEN
and add a second 01 (of a length smaller than 4996) to the fd.
Why is this file "vb" if there is only 1 lrecl?
If the file really does contain variable length records, you need to make sure that only data that has actually been read is referenced. . . |
|
Back to top |
|
|
JnanaR
New User
Joined: 20 Jul 2009 Posts: 23 Location: Mumbai
|
|
|
|
Hi Bill
It's IBM ENTERPRISE COBOL FOR Z/OS 4.1.0 |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Oops, apologies, was going by my memory (CRS, ya know)
Try this instead -
Code: |
FD INPUT-DRIVER-FILE
LABEL RECORDS ARE STANDARD
RECORDING MODE IS V
RECORD IS VARYING IN SIZE
FROM 1 TO 4996 CHARACTERS
DEPENDING ON WS-DR-LEN
BLOCK CONTAINS 0 RECORDS.
01 INPUT-DRIVER-REC PIC X(4996).
|
This is documented in the Application Programming Language Reference, associated with your given COBOL version/release.
There's a manual link on the main page for all your documentation needs.
Save it in your Favorites for easy reference or IBM Book Manager -
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/library
Bill |
|
Back to top |
|
|
JnanaR
New User
Joined: 20 Jul 2009 Posts: 23 Location: Mumbai
|
|
|
|
Thanks a lot Bill.
The compilation went thru fine.
Cheers |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
If the true maximum LRECL is 5000, then any place in the program you've specified 4996 (as it relates to this variable-length file), you need to change to 5000.
The compilation may have been good, but it's the successful execution of the program that matters.
Bill |
|
Back to top |
|
|
|