View previous topic :: View next topic
|
Author |
Message |
Itanium
Active User
Joined: 22 Jan 2006 Posts: 114 Location: India
|
|
|
|
How to declare a Variable Block VSAM file in FD Section and FILE-CONTROL Section. I have declared as below and during reads Return Code 04 is thrown.
Code: |
FILE-CONTROL.
SELECT FILEA ASSIGN TO FILEA
ORGANIZATION IS INDEXED
ACCESS IS SEQUENTIAL
RECORD KEY IS FILEA-KEY
FILE STATUS FILEA-STATUS.
FILE SECTION.
FD FILEA.
COPY FILEACPY.
|
Kindly let me know |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
RETURN CODE 04 or FILE STATUS 04? There is a huge difference -- RETURN CODE 04 is set by your program and we cannot tell you a thing about what it means since it will be in your code. FILE STATUS 04 means your VSAM file read a record which is not the same length as the fixed length record your FD 01 specified -- so even though the physical file is variable your COBOL program treated it as fixed length. This usually happens because you have only one fixed-length 01 under your FD, or you have multiple 01s defined but they are all the same length. |
|
Back to top |
|
|
Itanium
Active User
Joined: 22 Jan 2006 Posts: 114 Location: India
|
|
|
|
Thanks Robert for your quick reply.
Actually its FILE STATUS 04, and regarding the length of the file. It varies a from 36 - 20036 so we aren't able to define that much 01 under the FD. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
so we aren't able to define that much 01 under the FD. |
No COBOL reason you couldn't, but you know your site. Try this:
Code: |
FD FILEA RECORD VARYING FROM 36 TO 20036 CHARACTERS.
COPY FILEACPY. |
YOU have to do something to tell COBOL you've got variable length records, as the default is based on the 01 level(s) under the FD, and your 01 obviously is fixed length. |
|
Back to top |
|
|
Itanium
Active User
Joined: 22 Jan 2006 Posts: 114 Location: India
|
|
|
|
Thanks Bob. This worked |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Glad to hear it worked ... but no "Bob" here ... just a Robert. |
|
Back to top |
|
|
|