Computer Science 255
Exercise #7
Due: Various (see below)
A multi-step exercise, with documentation.
The file dia0:[matthews.cs255]PARTA.DAT and PARTB.DAT contain
records as follows:
FD PARTS-FILE
RECORD CONTAINS 15 TO 40 CHARACTERS
DATA RECORDS ARE BASIC-REC, INSERT-REC, MODIFY-REC.
01 BASIC-REC.
02 PNO.
04 DEPT PIC 9(4).
04 ITEM-NO PIC 9(3).
02 TIMESTAMP.
04 YYYY PIC 9(4).
04 DDD PIC 9(3).
02 TRANSACTION-CODE PIC X.
88 INSERT-REC VALUE "I".
88 DELETE-REC VALUE "D".
88 ADD-REC VALUE "A".
88 SUB-REC VALUE "S".
88 MODIFY-REC VALUES "A", "S".
01 INSERT-REC.
02 FILLER PIC X(15).
02 PNAME PIC X(20).
02 UNIT-COST PIC 999V99.
01 MODIFY-REC.
02 FILLER PIC X(15).
02 AMT PIC 9(3).
This file is terminated by a sentinel record with a PNO value of
"9999999" and a TIMESTAMP value of "9999999" and a transaction code
of "D".
The file dia0:[matthews.cs255]department.dat has records with the
following format:
01 DEPARTMENT-REC.
02 DNO PIC 9(4).
02 DNAME PIC X(20).
This file has exactly 10 records.
Step 1: (due Friday, Oct. 31)
- Write a program (call it MERGE.COB) which will merge two files
called TEMPA.DAT and TEMPB.DAT which have the same file
organization as PARTA.DAT and PARTB.DAT and which are in order
first by PNO and then TIMESTAMP into a single file called
TEMPC.DAT (in order by the same key, and with the same sentinel
record).
- Write a program (call it VALIDATE.COB) which will read in
TEMPC.DAT and DEPARTMENT.DAT and which will produce two files and
a report as follows:
- TRANSACTIONS.DAT, which contain records with no errors
discovered and which have the same format as the incoming record
except that insert transaction records are augmented by the
addition of the DEPARTMENT-NAME field between the PNAME and AMT
fields. The file should be terminated by the same sentinel as the
incoming fields
- REJECT.DAT which should contain only the rejected records (in
the case of invalid transaction codes, only the first 15
characters of the record should be written to the file).
- REJECT.LIS which reports on rejected records. Each rejected
record should be printed (no formatting necessary) followed by the
reasons for rejecting the record. Reasons for rejecting records
should be (1) Invalid department code, (2) DDD not in range, (3)
Invalid transaction code, and (4) unit cost not numeric (for
INSERT records only).
- Write a control script (call it SCRIPT01.COM) which will
perform the following actions:
- Sort PARTA.DAT and PARTB.DAT into ascending order by PNO and
TIMESTAMP. PARTA.DAT should be sorted into TEMPA.DAT, and
PARTB.DAT into TEMPB.DAT.
- Run your MERGE program, producing TEMPC.DAT.
- Run your VALIDATE program, producing TRANSACTIONS.DAT,
REJECT.DAT, and REJECT.LIS.
The remaining steps of this exercise will be added later. The
files PARTA.DAT, PARTB.DAT and DEPARTMENT.DAT are available, though
in very preliminary form (i.e., much will be added to the parts
files, and the department file may be changed, though the number of
records and the format of the records will not change).
Please let me know (send me email) if you find any problems with
the files or have any questions.