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

(In cobol) For this assignment you will produce a sequential update program usin

ID: 3682597 • Letter: #

Question

(In cobol) 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

Explanation / Answer

IDENTIFICATION DIVISION.

PROGRAM-ID. FILCMPR.

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

OBJECT-COMPUTER. IBM-390.

SOURCE-COMPUTER. IBM-390.

INPUT-OUTPUT SECTION.

FILE-CONTROL.

SELECT dealer_dat ASSIGN TO DD1

FILE STATUS IS FS1.

SELECT trans_dat ASSIGN TO DD2

FILE STATUS IS FS2.

SELECT dealer_out ASSIGN TO DD3

FILE STATUS IS FS3.

SELECT reject_dat ASSIGN TO DD4

FILE STATUS IS FS4.

DATA DIVISION.

FILE SECTION.

FD dealer_dat.

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.

FD MCHFILE.

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).

FD DEALER_OUT.

01 DD3_Dealer-Record.

03 DD3_Dealer-Number Pic X(8).

03 DD3_Dealer-Name.

05 DD3_Last-Name Pic X(25).

05 DD3_First-Name Pic X(15).

05 DD3_Middle-Name Pic X(10).

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

03 DD3_City Pic X(21).

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

03 DD3_Postal-Code Pic 9(5).

03 DD3_Consignment-Percent Pic 9(3).

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

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

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

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

FD REJECT_DAT.

01 DD4_Dealer-Record.

03 DD4_Dealer-Number Pic X(8).

03 DD4_Dealer-Name.

05 DD4_Last-Name Pic X(25).

05 DD4_First-Name Pic X(15).

05 DD4_Middle-Name Pic X(10).

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

03 DD4_City Pic X(21).

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

03 DD4_Postal-Code Pic 9(5).

03 DD4_Consignment-Percent Pic 9(3).

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

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

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

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

WORKING-STORAGE SECTION.

01 FS1 PIC X(02).

01 FS2 PIC X(02).

01 FS3 PIC X(02).

01 FS4 PIC X(02).

01 SWITCH1 PIC X(01).

88 EOF1 VALUE 'Y'.

88 NOT-EOF1 VALUE 'N'.

01 SWITCH2 PIC X(01).

88 EOF2 VALUE 'Y'.

88 NOT-EOF2 VALUE 'N'.

01 WS-EID PIC X(05).

01 WS_Dealer-Record.

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.

PROCEDURE DIVISION.

SET NOT-EOF1 TO TRUE

PERFORM OPEN-PARA.

PERFORM READ-PARA UNTIL EOF1.

PERFORM CLOSE-PARA.

STOP RUN.

OPEN-PARA.

OPEN INPUT DEALER_DAT

OPEN INPUT TRANS_DAT

OPEN OUTPUT DEALER_OUT.

OPEN OUTPUT REJECT_DAT.

DISPLAY ' DEALER_DAT OPEN STATUS ' FS1.

DISPLAY TRANS_DAT OPEN STATUS ' FS2.

DISPLAY ' DEALER_OUT OPEN STATUS ' FS3.

DISPLAY ' REJECT_DAT OPEN STATUS ' FS4.

READ-PARA.

IF FS1 = '00'

READ DEALER_DAT INTO WS_Dealer-Record

AT END

SET EOF1 TO TRUE

NOT AT END

MOVE EID1 TO WS-EID

SET NOT-EOF2 TO TRUE

PERFORM MATCH_OUT_PARA UNTIL EOF2

PERFORM CLOSE-OUT-PARA

END-READ

END-IF.

MATCH_OUT_PARA.

IF FS2='00'

IF Transaction-Dealer-Number = WS_Dealer-Number

PERFORM WRITE_DEALER_OUT_PARA

ELSE

PERFORM WRITE_REJECT_DAT_PARA

AT END_OF_FILE SET EOF2 TO TRUE

REJECT_DAT_PARA.

MOVE WS_Dealer-Record TO DD3_DEALER_RECORD.

WRITE DD3_DEALER_RECORD INTO REJECT_DAT_PARA.

WRITE_DEALER_OUT_PARA.

OPEN OUT DEALER_DAT.

ws3_CURRENT_TRANSACTION = Transaction-Qty * Transaction-price.

Write ws3_dealer_data into dealer_dat.

DD3_Commission-To-Date = ws3_current_transaction* ws_Consignment-Percent

ws3_Commission-To-Date += commision-To_Date

update ws3_deleat_data to dealer_dat.

CLOSE-OUT-PARA.

CLOSE reject_dat

DISPLAY ' OUTFILE CLOSE STATUS ' FS2.

CLOSE-PARA.

CLOSE delear_out

close dealer_dat

CLOSE trans_file.