Program:
For this assignment you will produce a sequential update program using techniques similar to the program I posted at the end of this homework. You are given two files, a "master" file with dealer information called Dealer.dat with record specification of:
01 Dealer-Record.
03 Dealer-NumberPic X(8).
03 Dealer-Name.
05 Last-NamePic X(25).
05 First-NamePic X(15).
05 Middle-NamePic X(10).
03 Address-Line-1Pic X(38).
03 CityPic X(21).
03 State-Or-CountryPic X(5).
03 Postal-CodePic 9(5).
03 Consignment-PercentPic 9(3).
03 Last-Sold-AmountPic S9(7)v99.
03 Last-Sold-DatePic 9(8).
03 Sold-To-DatePic S9(7)v99.
03 Commission-To-DatePic S9(7)v99.
and a transaction file called Trans.dat with record specification of:
01 Trans-Record.
03 Transaction-DatePic 9(8).
03 Transaction-Text.
05 Transaction-TypePic X(4).
05 Transaction-Dealer-NumberPic X(8).
03 Transaction-PricePicS9(7)v99.
03 Transaction-QtyPic 9(3).
Your task is to apply the transactions in Trans.dat to the master file Dealer.dat to produce a "new master" called Dealer-Out.dat. Transactions whose dealer number do not match a dealer number in Dealer.dat will be copied intact to a file Reject.dat.
During the apply step, if the Dealer-Number in Dealer-Record matches the Transaction-Dealer-Number in Trans-Record you will do the following:
• Calculate the value of the current transaction as the Transaction-Qty times the Transaction-Price.
• Update the Sold-To-Date in Dealer-Record by adding in the value of the current transaction.
• Calculate the current commission that the dealer receives by multiplying the value of the current transaction by the Consignment-Percent. Note that the Consignment-Percent is given as a number for 1 to 100, so you need to turn it into a decimal quantity.
• Update the Commission-To-Date by adding in the current commission.
If the date of the transaction is more recent than Last-Sold-Date, then 1) updateLast-Sold-Date to be the date of the transaction (in its original format), and 2)update Last-Sold-Amount to be the same as the value of the current transaction.
(Note that to do a date comparison, you need to reformat the date as YYYYMMDD, and compare the two dates using that format).
You will also keep a running total of:
• The number of transactions processed
• The number of rejected transactions, and
• The total of the commissions paid to dealers.
Prior to exiting the program, you should print these out to the display, so you should get an output similar to the following:
Begin Prog03
Processing Complete
Transactions Read 154
Transactions Rejected 149
Total of Commissions Paid 1,469.10
You should pass in the following
IDENTIFICATION DIVISION.
PROGRAM-ID. SEQ1000.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT RCTTRAN ASSIGN TO "RCTTRAN.DAT"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT OLDMAST ASSIGN TO "OLDMAST.DAT"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT NEWMAST ASSIGN TO "NEWMAST.DAT"
ORGANIZATION IS LINE SEQUENTIAL
FILE STATUS IS NEWMAST-FILE-STATUS.
SELECT ERRTRAN ASSIGN TO "ERRTRAN.DAT"
ORGANIZATION IS LINE SEQUENTIAL
FILE STATUS IS ERRTRAN-FILE-STATUS.
DATA DIVISION.
FILE SECTION.
FD RCTTRAN.
01 TRANSACTION-RECORD PIC X(23).
FD OLDMAST.
01 OLD-MASTER-RECORD PIC X(70).
FD NEWMAST.
01 NEW-MASTER-RECORD PIC X(70).
FD ERRTRAN.
01 ERROR-TRANSACTION PIC X(23).
WORKING-STORAGE SECTION.
01 SWITCHES.
05 FIRST-EXECUTION-SWITCH PIC X VALUE "Y".
88 FIRST-EXECUTION VALUE "Y".
05 ALL-RECORDS-PROCESSED-SWITCH PIC X VALUE "N".
88 ALL-RECORDS-PROCESSED VALUE "Y".
01 FILE-STATUS-FIELDS.
05 NEWMAST-FILE-STATUS PIC XX.
88 NEWMAST-SUCCESSFUL VALUE "00".
05 ERRTRAN-FILE-STATUS PIC XX.
88 ERRTRAN-SUCCESSFUL VALUE "00".
01 RECEIPT-TRANSACTION.
05 RT-ITEM-NO PIC X(5).
05 RT-VENDOR-NO PIC X(5).
05 RT-RECEIPT-DATE PIC X(8).
05 RT-RECEIPT-QUANTITY PIC S9(5).
01 INVENTORY-MASTER-RECORD.
05 IM-ITEM-NO PIC X(5).
05 IM-DESCRIPTIVE-DATA.
10 IM-ITEM-DESC PIC X(40).
10 IM-UNIT-COST PIC S9(3)V99.
10 IM-UNIT-PRICE PIC S9(3)V99.
05 IM-INVENTORY-DATA.
10 IM-REORDER-POINT PIC S9(5).
10 IM-ON-HAND PIC S9(5).
10 IM-ON-ORDER PIC S9(5).
PROCEDURE DIVISION.
000-UPDATE-INVENTORY-MASTER.
OPEN INPUT RCTTRAN
OLDMAST
OUTPUT NEWMAST
EXTEND ERRTRAN.
MOVE LOW-VALUE TO IM-ITEM-NO.
PERFORM 300-PROCESS-RECEIPT-TRAN
UNTIL ALL-RECORDS-PROCESSED.
CLOSE RCTTRAN
OLDMAST
NEWMAST
ERRTRAN.
STOP RUN.
300-PROCESS-RECEIPT-TRAN.
PERFORM 310-READ-RECEIPT-TRANSACTION.
PERFORM 320-PROCESS-INVENTORY-MASTER
UNTIL IM-ITEM-NO >= RT-ITEM-NO.
IF IM-ITEM-NO = HIGH-VALUE
AND RT-ITEM-NO = HIGH-VALUE
SET ALL-RECORDS-PROCESSED TO TRUE
ELSE
IF IM-ITEM-NO = RT-ITEM-NO
PERFORM 350-APPLY-RECEIPT-TRANSACTION
ELSE
PERFORM 360-WRITE-ERROR-TRANSACTION.
310-READ-RECEIPT-TRANSACTION.
READ RCTTRAN INTO RECEIPT-TRANSACTION
AT END
MOVE HIGH-VALUE TO RT-ITEM-NO.
320-PROCESS-INVENTORY-MASTER.
IF FIRST-EXECUTION
PERFORM 330-READ-OLD-MASTER
MOVE "N" TO FIRST-EXECUTION-SWITCH
ELSE
PERFORM 340-WRITE-NEW-MASTER
PERFORM 330-READ-OLD-MASTER.
330-READ-OLD-MASTER.
READ OLDMAST INTO INVENTORY-MASTER-RECORD
AT END
MOVE HIGH-VALUE TO IM-ITEM-NO.
340-WRITE-NEW-MASTER.
WRITE NEW-MASTER-RECORD FROM INVENTORY-MASTER-RECORD.
IF NOT NEWMAST-SUCCESSFUL
DISPLAY "WRITE ERROR ON NEWMAST FOR ITEM NUMBER "
IM-ITEM-NO
DISPLAY "FILE STATUS CODE IS " NEWMAST-FILE-STATUS
SET ALL-RECORDS-PROCESSED TO TRUE.
350-APPLY-RECEIPT-TRANSACTION.
ADD RT-RECEIPT-QUANTITY TO IM-ON-HAND.
SUBTRACT RT-RECEIPT-QUANTITY FROM IM-ON-ORDER.
360-WRITE-ERROR-TRANSACTION.
WRITE ERROR-TRANSACTION FROM RECEIPT-TRANSACTION.
IF NOT ERRTRAN-SUCCESSFUL
DISPLAY "WRITE ERROR ON ERRTRAN FOR ITEM NUMBER "
RT-ITEM-NO
DISPLAY "FILE STATUS CODE IS " ERRTRAN-FILE-STATUS
SET ALL-RECORDS-PROCESSED TO TRUE.
Attachment:- Dealer.rar