> -----Original Message-----
> From: IBM Mainframe Discussion List [mailto:[email protected]] On
> Behalf Of Frank Swarbrick
> Sent: Wednesday, January 06, 2010 2:44 PM
> To: [email protected]
> Subject: Cobol rewrite variable length record
> 
> We have a program that has the following in it:
> 
>     SELECT CVSCATF
>            ASSIGN TO AS-CVSCATF
>            ACCESS IS SEQUENTIAL
>            FILE STATUS IS FILE-STATUS.
> 
>  FD  CVSCATF
>      RECORD CONTAINS 17 TO 69 CHARACTERS.
>  01  CVSCATF-RECORD              PIC X(69).
>  01  CVSCATF-RECORD-L7           PIC X(17).
> 
>      OPEN I-O CVSCATF
>      READ CVSCATF INTO CVSC-AAT-RECORD
>      ...change something here...
>      REWRITE CVSCATF-RECORD FROM CVSC-AAT-RECORD
> 
> (Yes, we do check FILE-STATUS after each I-O.)
> 
> Some of the records are 17 characters and some are 69.  The file is a
VSAM
> ESDS.  CVSC-AAT-RECORD is a group data item that is *not* varying in
> length.
<Snipped>
 
I don't quite understand why or how it works at all on VSE, but the
program needs to differentiate between the record lengths at the REWRITE
statement.  If asked to review that code in a peer-review process I
would have called out this coding as a problem.  RECORD IS VARYING is
not required if your records have some internal indicator or length
field that tells you which one they are.  Then the code could read
something like this:

     OPEN I-O CVSCATF
     READ CVSCATF INTO CVSC-AAT-RECORD
     ...change something here...
     IF RECORD-IS-LENGTH-69-TYPE 
        REWRITE CVSCATF-RECORD    FROM CVSC-AAT-RECORD
     ELSE
        REWRITE CVSCATF-RECORD-17 FROM CVSC-AAT-RECORD
     END-IF

That should work anywhere for VSAM or SAM/QSAM, assuming of course that
your processing code doesn't change a length-69 into a length-17 or
vice-versa.

HTH

Peter


This message and any attachments are intended only for the use of the addressee 
and
may contain information that is privileged and confidential. If the reader of 
the 
message is not the intended recipient or an authorized representative of the
intended recipient, you are hereby notified that any dissemination of this
communication is strictly prohibited. If you have received this communication in
error, please notify us immediately by e-mail and delete the message and any
attachments from your system.


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to