Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

File status 04 in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
JnanaR

New User


Joined: 20 Jul 2009
Posts: 24
Location: Mumbai

PostPosted: Sat Oct 02, 2010 1:22 am    Post subject: File status 04 in COBOL
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat Oct 02, 2010 1:50 am    Post subject: Reply to: How to get rid of file status 04 in COBOL
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    Post subject:
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: 24
Location: Mumbai

PostPosted: Sat Oct 02, 2010 2:31 am    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat Oct 02, 2010 2:53 am    Post subject: Reply to: How to get rid of file status 04 in COBOL
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: 24
Location: Mumbai

PostPosted: Sat Oct 02, 2010 3:00 am    Post subject: Reply to: How to get rid of file status 04 in COBOL
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat Oct 02, 2010 3:02 am    Post subject: Reply to: How to get rid of file status 04 in COBOL
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

Site Director


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

PostPosted: Sat Oct 02, 2010 3:06 am    Post subject:
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: 24
Location: Mumbai

PostPosted: Sat Oct 02, 2010 3:12 am    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat Oct 02, 2010 3:14 am    Post subject: Reply to: How to get rid of file status 04 in COBOL
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 -

http://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: 24
Location: Mumbai

PostPosted: Sat Oct 02, 2010 3:31 am    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat Oct 02, 2010 3:51 am    Post subject: Reply to: How to get rid of file status 04 in COBOL
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us