COBOL code with VSAM gives RC-04 without RECORD VARYING.

Virtual Storage Access method - ESDS, KSDS, RRDS & LDS. Basic direct access method, Basic sequential -, Queued sequential -, Basic partitioned -, Indexed sequential -, Object - access method.
Post Reply
Pradeep Singh
Registered Member
Posts: 22
Joined: Thu Aug 21, 2014 7:12 am

COBOL code with VSAM gives RC-04 without RECORD VARYING.

Post by Pradeep Singh »

 I am running one COBOL pgm which is reading one VSAM file. Below is ithe input output section in my pgm.

Code: Select all

FILE-CONTROL.
 SELECT IN-FILE         ASSIGN TO INFILE             
                        ORGANIZATION IS INDEXED           
                        ACCESS MODE  IS RANDOM            
                        RECORD KEY   IS IN-KEY                                
                        FILE STATUS  IS WS-IN-STATUS.

FILE SECTION.
FD IN-FILE IS EXTERNAL
COPY INPUTREC.
But at execution, the program failes with RC=04.

When FD is changed to the follwoing, it works:

Code: Select all

FILE SECTION.
FD IN-FILE IS EXTERNAL
RECORD VARYING IN SIZE FROM 1 TO 200. 
COPY INLAYOUT.

It works fine.

I did this because, while searching I got some hint that when in FD we have only one record even if the file is VB it treats it is FB.
And FB would have record contains or Varying clause. Is it true? Confusing.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1886
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: COBOL code with VSAM gives RC-04 without RECORD VARYING.

Post by Robert Sample »

IF the data set has records of varying length, you MUST tell COBOL this.  You can do with with a RECORD VARYING clause, or by having multiple FD 01 records with different record lengths, or by having a single FD 01 with OCCURS x TO y in it.  If you do not have any of these, COBOL makes the file declaration fixed length, which will generate a FILE STATUS of non-zero on OPEN or READ or WRITE.
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: COBOL code with VSAM gives RC-04 without RECORD VARYING.

Post by nicc »

Please use the code tags when posting code, data, screen 'shots' (cut'n'paste) and anything else requiring a fixed pitch font to convey correct information.
Regards
Nic
Pradeep Singh
Registered Member
Posts: 22
Joined: Thu Aug 21, 2014 7:12 am

Re: COBOL code with VSAM gives RC-04 without RECORD VARYING.

Post by Pradeep Singh »

Robert Sample wrote:IF the data set has records of varying length, you MUST tell COBOL this.  You can do with with a RECORD VARYING clause, or by having multiple FD 01 records with different record lengths, or by having a single FD 01 with OCCURS x TO y in it.  If you do not have any of these, COBOL makes the file declaration fixed length, which will generate a FILE STATUS of non-zero on OPEN or READ or WRITE.
Thanks. That is helpful in understanding the RC=04. Kudos! :)
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “SMS & VSAM and BDAM, BSAM, QSAM, BPAM, ISAM, OAM.”