****************************************
      * Program name: reccopy.cbl
      * This program provides an example
      * of how to read a comma delimited text
      * file that contains physical records
      * that vary in size, and create a new
      * text file that has consistent 100 byte
      * physical records sizes.
      * It is important have data files with
      * consistent physical record sizes in
      * order for the CS REWRITE and POSITION
      * commands to function properly.
      *
      * Copyright 2000 Deskware, Inc.
      ****************************************                                                             
       FD `INPUT.CSV` RECORD IS 100 BYTES.
       1  input_rec.
           5  input_field_1  PIC X(33).
           5  input_field_2  PIC X(32).
           5  input_field_3  PIC X(30).
           5  input_field_4  PIC X.

       FD `OUTPUT.DAT` RECORD IS 100 BYTES. 
       1  eof   PIC X VALUE `N`.

       OPEN `INPUT.CSV`  FOR READING DELIMITED WITH `,`.
       OPEN `OUTPUT.DAT` FOR WRITING DELIMITED WITH `,`.

       PERFORM UNTIL eof = `Y`
          READ `INPUT.CSV` INTO input_rec AT END MOVE `Y` TO eof
          WRITE input_rec TO `OUTPUT.DAT`
       END-PERFORM.

       CLOSE `INPUT.CSV`.
       CLOSE `OUTPUT.DAT`.