IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

File status 04 in COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
JnanaR

New User


Joined: 20 Jul 2009
Posts: 23
Location: Mumbai

PostPosted: Sat Oct 02, 2010 1:22 am
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sat Oct 02, 2010 1:50 am
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Oct 02, 2010 1:52 am
Reply with quote

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
View user's profile Send private message
JnanaR

New User


Joined: 20 Jul 2009
Posts: 23
Location: Mumbai

PostPosted: Sat Oct 02, 2010 2:31 am
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sat Oct 02, 2010 2:53 am
Reply with quote

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.... icon_eek.gif

Bill
Back to top
View user's profile Send private message
JnanaR

New User


Joined: 20 Jul 2009
Posts: 23
Location: Mumbai

PostPosted: Sat Oct 02, 2010 3:00 am
Reply with quote

I think it's COBOL 3.I am not sure..
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sat Oct 02, 2010 3:02 am
Reply with quote

The COBOL version/release should be printed on each page of the compilation listing. Can you post this exact value?

Bill
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Oct 02, 2010 3:06 am
Reply with quote

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
View user's profile Send private message
JnanaR

New User


Joined: 20 Jul 2009
Posts: 23
Location: Mumbai

PostPosted: Sat Oct 02, 2010 3:12 am
Reply with quote

Hi Bill

It's IBM ENTERPRISE COBOL FOR Z/OS 4.1.0
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sat Oct 02, 2010 3:14 am
Reply with quote

Oops, apologies, was going by my memory (CRS, ya know) icon_eek.gif

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. icon_wink.gif

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
View user's profile Send private message
JnanaR

New User


Joined: 20 Jul 2009
Posts: 23
Location: Mumbai

PostPosted: Sat Oct 02, 2010 3:31 am
Reply with quote

Thanks a lot Bill.
The compilation went thru fine.
Cheers
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sat Oct 02, 2010 3:51 am
Reply with quote

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. icon_wink.gif

Bill
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top