Page 1 of 1

Help! Open Error Code 39

PostPosted: Thu May 02, 2013 9:40 am
by jellypuno
Hi,

I am trying to Key read a VSAM File that is in a Variable Block Format. But I am Having an Error COde 39 in the file opening. Please Help! :cry:

File Length: 4500 to 32752


SELECT FILE 1             ASSIGN TO FILE1
                                  ORGANIZATION IS INDEXED
                                  ACCESS MODE IS DYNAMIC
                                  RECORD KEY IS FILE1-KEY
                                  FILE STATUS IS FILE1-STATUS.


FD FILE1.
     RECORD IS VARYING FROM 4500 TO 32752
     DEPENDING ON W-REC-SIZE.
01 FILE1-RECORD.
     05 FILE1-KEY         PIC X(26).
     05 FILLER             PIC X(32726).


77 W-REC-SIZE          PIC 9(05).


Re: Help! Open Error Code 39

PostPosted: Thu May 02, 2013 2:17 pm
by Robert Sample
A file status 39 means that your COBOL program does not have the file defined in the same way that the file exists on the disk. As such, what you have posted is less than half the information needed to help you. Also needed an IDCAMS LISTCAT of the file, and the data map showing what COBOL knows about the file.

Re: Help! Open Error Code 39

PostPosted: Thu May 02, 2013 2:31 pm
by jellypuno
Hi,

Thanks for your reply. Im not really sure what you mean by data map. But the file is defined as follows:

Type: KSDS
KEYLEN: 26
AVGLRECL: 4500
MAXLRECL: 32752

Can you tell me what other info that you need from the LISTCAT?

Re: Help! Open Error Code 39

PostPosted: Thu May 02, 2013 2:45 pm
by Robert Sample
Things that need to be looked at include whether or not the file has an alternate index -- if so, this must be described to COBOL. Plus, the LISTCAT shows the ACTUAL file attributes, not just what you say they are. People have been known to misunderstand how a file is defined, so the LISTCAT allows the file attributes as the system knows them to be shown.

Re: Help! Open Error Code 39

PostPosted: Thu May 02, 2013 3:13 pm
by BillyBoyo
Note that IS VARYING specifies the minimum to maximum length, yet you have specified the "average" record length. I don't think this would cause an error at OPEN. Perhaps not even with READ or WRITE. It definitely can cause a problem when "rewriting" a record.

If using a VSAM file, you have an "extended file status" available, so it is good to always include that (contents contain details of what VSAM has to say about the last IO operation).

Re: Help! Open Error Code 39

PostPosted: Thu May 02, 2013 3:30 pm
by jellypuno
Hi,

@ Robert: I cannot paste the whole listcat of the file here due to access reasons. But the file doesn't have an alternate index. From what I see it is defined as a regular KSDS file in a Variable Block format.

@Billy How do you get the extended file status? Im sorry i know it's a very basic question but I can only get the error code 39. Anyway, regarding your first statement, you're right it shouldn't cause an error at opening but yet it did. I really tried everything that I know but somehow there is still an error between the file definition and the cobol program. I'm guessing maybe im accessing it as DYNAMIC? Is there a limitation for Variable Block files accessed as DYNAMIC in Cobol? The sample codes that I have seen in Google is Variable Block files are accessed Sequentially.

Re: Help! Open Error Code 39

PostPosted: Thu May 02, 2013 3:43 pm
by enrico-sorichetti

Re: Help! Open Error Code 39

PostPosted: Thu May 02, 2013 3:58 pm
by Robert Sample
If you cannot provide objective indications of how the file is defined to the system, there's not going to be much we can do to help you. You have already told us how you defined the file to COBOL, and the file status 39 indicates that you did not specify the file correctly. Merely repeating what is known to be wrong isn't helping. And you never have posted the Data Division Map from the COBOL compile showing your file. The key information is on the first line of hte file specification:
0Data Division Map
0Data Definition Attribute codes (rightmost column) have the following meanings:
     D = Object of OCCURS DEPENDING    G = GLOBAL                             S = Spanned file
     E = EXTERNAL                      O = Has OCCURS clause                  U = Undefined format file
     F = Fixed-length file             OG= Group has own length definition    V = Variable-length file
     FB= Fixed-length blocked file     R = REDEFINES                          VB= Variable-length blocked file
0Source   Hierarchy and                                    Base       Hex-Displacement  Asmblr Data                    Data Def
 LineID   Data Name                                        Locator    Blk   Structure   Definition      Data Type      Attributes
      2  PROGRAM-ID READSMF-----------------------------------------------------------------------------------------------------*
     18   FD SMF-FILE. . . . . . . . . . . . . . . . . . .                                              QSAM           S
This tells you how COBOL sees the file and is the first thing that needs to be resolved.

Re: Help! Open Error Code 39

PostPosted: Thu May 02, 2013 4:18 pm
by BillyBoyo
A VSAM file is not a "Variable Blocked" file. It is a VSAM file. It can contain records of different lengths, but VSAM does not have "blocks" in the way that the term is used for QSAM/PS/"flat" files. VSAM has Control Intervals, which contain records (or data or index records) and Control Areas which contain Control Intervals.

Respond to what Robert has asked. You will see from the Data Map what Cobol thinks the file is, and from the LISTCAT what the file actually is. You also need to ensure that you have the same dataset name on the DD statement in the JCL as that which you produce the LISTCAT for.

So, Data Map, LISTCAT, and DD name from the JCL. Check the sysout for the step as well, you may have some messages there (always worth checking).

Re: Help! Open Error Code 39

PostPosted: Thu May 02, 2013 4:32 pm
by Robert Sample
As far as the extended file status, when you code
FILE STATUS IS XXX YYY
XXX is the 2-byte fiel status available for all files. YYY is the extended file status, only for VSAM files, and is a 6-byte group defined as
01  YYY.
    05  YYY-RETURN   PIC S9(04) COMP-5.
    05  YYY-FUNCTION PIC S9(04) COMP-5.
    05  YYY-FEEDBACK PIC S9(04) COMP-5.
and contains the VSAM return code, function code, and feedback code respectively.