HP 3000 Manuals

Example 9: Data File Conversion [ HP COBOL II/XL Migration Guide ] MPE/iX 5.0 Documentation


HP COBOL II/XL Migration Guide

Example 9:  Data File Conversion 

The following program is a sample program that converts a data file
containing 16-bit synchronized data to a file that contains 32-bit
synchronized data.  Also, the INDEX data item in the file is changed to a
numeric item.  Note that the data in this new numeric item is invalid and
cannot be used, but the rest of the record now can be read and processed
on MPE XL systems.  To use the INDEX data item or the converted numeric
form, you need to recreate the data file.  You can convert INDEX data
items on an MPE V system and modify your program accordingly.

         $CONTROL MAP
          IDENTIFICATION DIVISION.
          PROGRAM-ID. CONVERT.
         * This program converts a file from 16-bit to 32-bit synchronization
         * to gain performance benefits.  This program may be run on MPE V
         * or MPE XL systems.
          ENVIRONMENT DIVISION.
          CONFIGURATION SECTION.
          INPUT-OUTPUT SECTION.
          FILE-CONTROL.
              SELECT IN-FILE ASSIGN TO "IFILE".
              SELECT OUT-FILE ASSIGN TO "OFILE".
          DATA DIVISION.
          FILE SECTION.
         $CONTROL SYNC16
          FD  IN-FILE.
          01  I-REC.
              03 F1              PIC X.
              03 F2              PIC S9(9) COMP SYNC.
              03 F3              PIC X.
              03 F4              PIC S9(4) COMP SYNC.
              03 F5              PIC X.
              03 F6              USAGE IS INDEX.
              03 F7              PIC X.
         $CONTROL SYNC32
          FD  OUT-FILE.
          01  O-REC.
              03 F1              PIC X.
              03 F2              PIC S9(9) COMP SYNC.
              03 F3              PIC X.
         * To achieve maximum performance gain, change F4 to PIC S9(9).
              03 F4              PIC S9(9) COMP SYNC.
              03 F5              PIC X.
              03 F6-HAS-NO-DATA  PIC S9(9) COMP SYNC.
              03 F7              PIC X.
          WORKING-STORAGE SECTION.
          77 EOF-SW              PIC XXX VALUE "NO".
              88 EOF                     VALUE "YES".

          PROCEDURE DIVISION.
          P.
              OPEN INPUT IN-FILE
                  OUTPUT OUT-FILE.
              PERFORM UNTIL EOF
                  READ IN-FILE
                      AT END SET EOF TO TRUE
                      NOT AT END
                  MOVE CORR I-REC TO O-REC
                  WRITE O-REC
                  END-READ
              END-PERFORM
              CLOSE IN-FILE OUT-FILE.
              STOP RUN.



MPE/iX 5.0 Documentation