Page 1 of 2

Rewrite VSAM in Cobol

PostPosted: Wed Nov 09, 2011 9:14 pm
by sallyroselle
I am currently trying to rewrite a VSAM record in cobol. The record that I am replacing the original with is a different length, but is much shorter than the maximum length allowed to the variable length VSAM. I keep getting a VSAM file status of 44, meaning

A boundary violation exists because an attempt was made to rewrite a record to a file and the record was not the same size as the record being replaced, or an attempt was made to write or rewrite a record that was larger than the largest or smaller than the smallest record allowed by the RECORD IS VARYING clause of the associated file-name.

Do I have one of my definitions set up incorrectly? How can I rewrite this record without deleting the first one and writing a whole new one? Thanks!

Re: Rewrite VSAM in Cobol

PostPosted: Wed Nov 09, 2011 9:22 pm
by NicC
You cannot unless the record length stays the same - it has to fit into the same space that the original record was in.

Re: Rewrite VSAM in Cobol

PostPosted: Wed Nov 09, 2011 9:32 pm
by sallyroselle
I was thinking the same thing, but on the IBM site located here

http://publib.boulder.ibm.com/infocente ... pvsm18.htm

I found

Replacing records in a VSAM file

'For indexed files or variable-length relative files, you can change the length of the record you replace.'

are they referring to something else?

Thanks for your help!

Re: Rewrite VSAM in Cobol

PostPosted: Wed Nov 09, 2011 9:46 pm
by BillyBoyo
Can you show your select/fd the message number and any other messages and a listcat of the dataset?

Are you reading the record before attempting to update it? If so, how are you reading it?

Re: Rewrite VSAM in Cobol

PostPosted: Wed Nov 09, 2011 9:59 pm
by sallyroselle
FILE-CONTROL.                                               
    SELECT REQ-FILE ASSIGN TO EDVRTRQH                       
                    ORGANIZATION IS INDEXED                 
                    ACCESS       IS RANDOM                   
                    RECORD KEY   IS REQ-RECORD-KEY           
                    FILE STATUS  IS VSAM-FILE-STATUS-IND     
                                    VC-VSAM-CODE.           
                                                             
DATA DIVISION.                                               
                                                             
FILE SECTION.                                               
                                                             
FD  REQ-FILE                                                 
    BLOCK CONTAINS 0 CHARACTERS                             
    DATA RECORD IS REQ-FILE-RECORD.                         



I am reading it before I update it using with a straight read. I'm opening it with an open I-O.

I'm force dumping it after getting a 44 VSAM file status code.

Re: Rewrite VSAM in Cobol

PostPosted: Wed Nov 09, 2011 10:24 pm
by Robert Sample
Does REQ-FILE-RECORD have an OCCURS DEPENDING ON in it? As someone asked, what does the LISTCAT look like for the VSAM file?

Re: Rewrite VSAM in Cobol

PostPosted: Wed Nov 09, 2011 10:39 pm
by BillyBoyo
You say you have a new length record, but you need to show how you are doing that. Is it with ODO? If so, is your new record longer than the maximum on the DEPENDING ON field? Did you get any error message in the JES output for the job?

Re: Rewrite VSAM in Cobol

PostPosted: Wed Nov 09, 2011 11:04 pm
by sallyroselle
01  REQ-FILE-RECORD.                                           
    03  REQ-RECORD-KEY.                                         
        05  RRK-ELEMENT               PIC X(6).                 
        05  RRK-RELEASE-DATE          PIC X(8).                 
        05  RRK-VERSION               PIC X.                   
    03  FILLER                        PIC X                     
        OCCURS 1 TO 1621 TIMES DEPENDING ON REQ-RECORD-LENGTH. 



When this record was first created, it ws 90 characters. I'm now expanding a message and it's trying to write 120 characters.

Re: Rewrite VSAM in Cobol

PostPosted: Wed Nov 09, 2011 11:06 pm
by sallyroselle
It looks like the record length is getting set by the record that I read- is this the longest it could be? Maybe I should change how the record length is being set... (use the longer of the read record and the one I am trying to update it with)

Re: Rewrite VSAM in Cobol

PostPosted: Wed Nov 09, 2011 11:29 pm
by BillyBoyo
Where are you getting REQ-RECORD-LENGTH?

EDIT: The reference you point to in the manual states that you can do it, and it is for the sort of thing you are trying to do. The message for your 44 is a little unclear. It first says you can't do it, which you can't for an ESDS, and then "an attempt was made to write or rewrite a record that was larger than the largest or smaller than the smallest record allowed by the RECORD IS VARYING clause of the associated file-name." You don't have RECORD IS VARYING. There is nothing I can find for any "default" value without that, so maybe you could try to include that? I don't know if it should help, because with the ODO Cobol should already know the records can vary. I don't imagine that your VSAM definition is the problem, even though we haven't seen it yet, because you are way away from the maximum. Are you definitely sure you have 120 when you do the re-write, not some ludicrous low or high count in there?