Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

NOTE COBOL COBOL COBOL COBOL COBOL PROGRAM For this assignment you will produce

ID: 3675526 • Letter: N

Question

NOTE COBOL COBOL COBOL COBOL COBOL PROGRAM

For this assignment you will produce a sequential update program using techniques similar to those in SS3. You are given two files, a "master" file with dealer information called Dealer.dat with record specification of:

01 Dealer-Record.

    03 Dealer-Number                    Pic X(8).

    03 Dealer-Name.

       05 Last-Name                    Pic X(25).

       05 First-Name                   Pic X(15).

       05 Middle-Name                  Pic X(10).

    03 Address-Line-1                   Pic X(38).

    03 City                             Pic X(21).

    03 State-Or-Country                Pic X(5).

    03 Postal-Code                      Pic 9(5).

    03 Consignment-Percent              Pic 9(3).

    03 Last-Sold-Amount                 Pic S9(7)v99.

    03 Last-Sold-Date                   Pic 9(8).

    03 Sold-To-Date                     Pic S9(7)v99.

    03 Commission-To-Date               Pic S9(7)v99.

and a transaction file called Trans.dat with record specification of:

01 Trans-Record.

    03 Transaction-Date                 Pic 9(8).

    03 Transaction-Text.

       05 Transaction-Type             Pic X(4).

       05 Transaction-Dealer-Number    Pic X(8).

    03 Transaction-Price                Pic S9(7)v99.

    03 Transaction-Qty                  Pic 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) update Last-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

Your Prog03.cbl file

Your Dealer-Out.dat file

Your Reject.dat file

Dealer.dat

Explanation / Answer

    03 Dealer-Number                    Pic X(8).

    03 Dealer-Name.

       05 Last-Name                    Pic X(25).

       05 First-Name                   Pic X(15).

       05 Middle-Name                  Pic X(10).

    03 Address-Line-1                   Pic X(38).

    03 City                             Pic X(21).

    03 State-Or-Country                Pic X(5).

    03 Postal-Code                      Pic 9(5).

    03 Consignment-Percent              Pic 9(3).

    03 Last-Sold-Amount                 Pic S9(7)v99.

    03 Last-Sold-Date                   Pic 9(8).

    03 Sold-To-Date                     Pic S9(7)v99.

    03 Commission-To-Date               Pic S9(7)v99.

002200 FD TRANS_DAT

01 Trans-Record.

    03 Transaction-Date                 Pic 9(8).

    03 Transaction-Text.

       05 Transaction-Type             Pic X(4).

       05 Transaction-Dealer-Number    Pic X(8).

    03 Transaction-Price                Pic S9(7)v99.

    03 Transaction-Qty                  Pic 9(3).

01 REJECT-Record.

    03 REJTransaction-Date                 Pic 9(8).

    03 REJTransaction-Text.

       05 REJTransaction-Type             Pic X(4).

       05 REJTransaction-Dealer-Number    Pic X(8).

    03 REJTransaction-Price                Pic S9(7)v99.

    03 REJTransaction-Qty                  Pic 9(3).

    03 WS-Dealer-Number                    Pic X(8).

    03 WS-Dealer-Name.

       05 WS-Last-Name                    Pic X(25).

       05 WS-First-Name                   Pic X(15).

       05 WS-Middle-Name                  Pic X(10).

    03 WS-Address-Line-1                   Pic X(38).

    03 WS-City                             Pic X(21).

    03 WS-State-Or-Country                Pic X(5).

    03 WS-Postal-Code                      Pic 9(5).

    03 WS-Consignment-Percent              Pic 9(3).

    03 WS-Last-Sold-Amount                 Pic S9(7)v99.

    03 WS-Last-Sold-Date                   Pic 9(8).

    03 WS-Sold-To-Date                     Pic S9(7)v99.

    03 WS-Commission-To-Date               Pic S9(7)v99.

01 WS-Trans-Record.

    03 WS-Transaction-Date                 Pic 9(8).

    03 WS-Transaction-Text.

       05 WS-Transaction-Type             Pic X(4).

       05 WS-Transaction-Dealer-Number    Pic X(8).

    03 WS-Transaction-Price                Pic S9(7)v99.

    03 WS-Transaction-Qty                  Pic 9(3).

05 WS-KEYMATCH PIC 9.

05 WS-CUR-TRANS PIC 9(8).

P0300-WRITE-REJECT-DAT

WRITE WS-TRANS-RECORD TO REJECT-Record.

ADD 1 TO TRANSACTION-REJECT

P0300-EXIT