Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Program In ''COBOL COBOL COBOL COBOL'' For this assignment you will produce a sequential maintenance program using techniques similar to those in SS3. You are

Program In ''COBOL COBOL COBOL COBOL''

For this assignment you will produce a sequential maintenance program using techniques similar to those in SS3. You are given two files, a "master" file with dealer information called Account-Master-File-In.txt with record specification of:

01 ACCOUNT-MASTER-RECORD.

05 OM-ACCOUNT-NUMBER PIC X(05).

05 OM-ACCOUNT-NAME PIC X(20).

05 OM-DATE-OF-LAST-DEPOSIT PIC X(8).

05 OM-ACCOUNT-BALANCE PIC S9(6)V99.

and a transaction file called Transaction-File-In.txt with record specification of:

01 MAINTENANCE-TRANSACTION-RECORD.

05 MT-TRANSACTION-CODE PIC X.

88 MT-NEW-ACCOUNT VALUE "1".

88 MT-DEPOSIT VALUE "2".

88 MT-WITHDRAWAL VALUE "3".

88 MT-NAME-CHANGE VALUE "4".

88 MT-DELETION VALUE "5".

05 MT-ACCOUNT-NUMBER PIC X(5).

05 MT-DEPOSIT-AMOUNT PIC 9(6)v99.

05 MT-WITHDRAWAL-AMOUNT

REDEFINES MT-DEPOSIT-AMOUNT

PIC 9(6)V99.

05 MT-DEPOSITOR-NAME-FOR-ADD PIC X(20).

88 MT-DEPOSITOR-NAME-MISSING VALUE SPACES.

01 NAME-CHANGE-RECORD

REDEFINES MAINTENANCE-TRANSACTION-RECORD.

05 PIC X(6).

05 MT-DEPOSITOR-NEW-NAME PIC X(20).

05 PIC X(8).

Your task is to apply the transactions in the transaction file Transaction-File-In.txt to produce a "new master" called Account-Master-File-Out.txt. Error transactions

should be copied intact to Error-File.txt.

You should use the posted sequential maintenance cobol file discussed in the slides for all "control" needed. You should use the same name for switches and the control variables.

One change is required in the "control" part of the program in the slides. You should detect when multiple adds for the same record are attempted. Examination of the old master will reveal that this occurs for record 371.

With the exception of the multiple add detection, the only modification you should make is in the data manipulation part of the program.

Note that the Maintenance-Transaction-Record has "formats", i.e. the record can have multiple structures depending on the type of transaction record it is. There are 5 types of transactions:

adding an account (MT-TRANSACTION-CODE = 1)

deposit into an account (MT-TRANSACTION-CODE = 2)

withdrawal from an account (MT-TRANSACTION-CODE = 3)

changing the name on an account (MT-TRANSACTION-CODE = 4)

deleting an account (MT-TRANSACTION-CODE = 5)

All of the formats have MT-TRANSACTION-CODE and MT-ACCOUNT-NUMBER.

For deposits, the amount deposited is MT-DEPOSIT-AMOUNT.

The REDEFINES MT-DEPOSIT-AMOUNT redefines the storage space for MT-DEPOSIT-AMOUNT to be called MT-WITHDRAWAL-AMOUNT when the transaction is a withdrawal.

The MT-DEPOSITOR-FOR-ADD is present only for an add transaction, otherwise it is spaces (because the name for the account does not change for a deposit or withdrawal).

If the transaction is a name change, then the storage space beyond the transaction code and account number becomes the new name associated with an existing account. 8 spaces is added after the new name to make the record size 34 characters. This is indicated by NAME-CHANGE-RECORD which redefines the entire (34 characters) of the MAINTENANCE-TRANSACTION-RECORD.

Note that all formats end up being 34 characters total.

Note that in the context of the terminology used in the slides, deposits, withdrawals, and name changes are all "changes", adding an account is an "add", and deleting an account is a "delete".

Note also, that a withdrawal may end up causing an account to have a negative balance. This will cause strange characters to be printed for the last digit of the balance in the output file because the negative sign is stored in the same byte as the last digit.

Account-Master-File-In.txt

00007ROSE BUCCI 2016032200100784 00014ROBERT DAVIS M.D. 2016032200001000 00021LORICE MONTI 2016032200012500 00028MICHAEL SMITH 2016032200700159 00032JOSEPH CAMILLO 2015032200002500 00035JOHN J. LEHMAN 2016032200015000 00049JAY GREENE 2016032200015000 00056EVELYN SLATER 2016032200000100 00070PATRICK J. LEE 2016032200050000 00077LESLIE MINSKY 2016032200001037 00084JOHN DAPRINO 2016032200150000 00091JOE'S DELI 2016032200010000 00098GEORGE CULHANE 2016032200050000 00105ONE DAY CLEANERS 2016032200005000 00112ROSEMARY LANE 2016032200025000 00126JAMES BUDD 2016032200075000 00133PAUL LERNER, D.D.S. 2016032200100000 00140BETH FALLON 2016032200002575 00161ROBERT RYAN 2016032200002450 00168KELLY HEDERMAN 2016032200012550 00175MARY KEATING 2016032200001000 00189J. & L. CAIN 2016032200003500 00196IMPERIAL FLORIST 2016032200015000 00203JOYCE MITCHELL 2016032200000500 00210JERRY PARKS 2016032200025000 00217CARL CALDERON 2016032200005000 00224JOHN WILLIAMS 2016032200017550 00231BILL WILLIAMS 2016032200055500 00238KEVIN PARKER 2016032200001000 00245FRANK CAPUTO 2016032200003500 00252GENE GALLI 2016032200001500 00266MARTIN LANG 2016032200009957 00273VITO CACACI 2016032200027500 00280COMMUNITY DRUGS 2016032200002000 00287SOLOMON CHAPELS 2016032200001500 00294JOHN BURKE 2016032200150000 00308JOE GARCIA 2016032200200000 00315GRACE MICELI 2016032200025000 00329GUY VOLPONE 2016032200001000 00343JOE & MARY SESSA 2016032200100000 00350ROGER SHAW 2016032200250000 

Transaction-File-In.txt

30001400100000 20002100012750 30002800150050 20002800015327 20006300007500 20007700015000 400084JOHN & SALLY DUPRINO 20008400357429 20009100150000 20009100120000 30009100050000 400098GEORGE & ANN CULHANE 30011900002735 20012600035000 20013300256300 400140BETH DENNY 20016100125634 30016800011000 500168 20017500019202 200182 20021000025000 20021000025000 20021000025000 500232 30025929390000 20027300172500 20028000231700 20030100005763 10030800017000AL MARRELLA 20030800005000 80031500013798 20032200006875 10035700001000ROBIN RATANSKI 10036400150000JOSE TORRES 20037100015000 10037100015000ALISE MARKOVITZ 10037100001000THOMAS HERR 70038500007500JAMES WASHINGTON 10039200007500INEZ WASHINGTON 10039800001000JUAN ALVAREZ 10041300010000BILL HAYES 10042000150000JOHN RICE 70042700002500GREG PRUITT 

IDENTIFICATION DIVISION.

PROGRAM-ID. FILEMNT.

ENVIRONMENT DIVISION.

INPUT-OUTPUT SECTION.

FILE-CONTROL.

SELECT MNTTRAN ASSIGN TO "MNTTRAN.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 MNTTRAN.

01 TRANSACTION-RECORD PIC X(61).

FD OLDMAST.

01 OLD-MASTER-RECORD PIC X(70).

FD NEWMAST.

01 NEW-MASTER-RECORD.

05 NM-ITEM-NO PIC X(5).

05 NM-DESCRIPTIVE-DATA.

10 NM-ITEM-DESC PIC X(40).

10 NM-UNIT-COST PIC S9(3)V99.

10 NM-UNIT-PRICE PIC S9(3)V99.

05 NM-INVENTORY-DATA.

10 NM-REORDER-POINT PIC S9(5).

10 NM-ON-HAND PIC S9(5).

10 NM-ON-ORDER PIC S9(5).

FD ERRTRAN.

01 ERROR-TRANSACTION PIC X(61).

WORKING-STORAGE SECTION.

01 SWITCHES.

05 ALL-RECORDS-PROCESSED-SWITCH PIC X VALUE "N".

88 ALL-RECORDS-PROCESSED VALUE "Y".

05 NEED-TRANSACTION-SWITCH PIC X VALUE "Y".

88 NEED-TRANSACTION VALUE "Y".

05 NEED-MASTER-SWITCH PIC X VALUE "Y".

88 NEED-MASTER VALUE "Y".

05 WRITE-MASTER-SWITCH PIC X VALUE "N".

88 WRITE-MASTER 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 MAINTENANCE-TRANSACTION.

05 MT-TRANSACTION-CODE PIC X.

88 DELETE-RECORD VALUE "1".

88 ADD-RECORD VALUE "2".

88 CHANGE-RECORD VALUE "3".

05 MT-MASTER-DATA.

10 MT-ITEM-NO PIC X(5).

10 MT-ITEM-DESC PIC X(40).

10 MT-UNIT-COST PIC S9(3)V99.

10 MT-UNIT-PRICE PIC S9(3)V99.

10 MT-REORDER-POINT 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-MAINTAIN-INVENTORY-FILE.

OPEN INPUT OLDMAST

MNTTRAN

OUTPUT NEWMAST

ERRTRAN.

PERFORM 300-MAINTAIN-INVENTORY-RECORD

UNTIL ALL-RECORDS-PROCESSED.

CLOSE MNTTRAN

OLDMAST

NEWMAST

ERRTRAN.

STOP RUN.

300-MAINTAIN-INVENTORY-RECORD.

IF NEED-TRANSACTION

PERFORM 310-READ-INVENTORY-TRANSACTION

MOVE "N" TO NEED-TRANSACTION-SWITCH.

IF NEED-MASTER

PERFORM 320-READ-OLD-MASTER

MOVE "N" TO NEED-MASTER-SWITCH.

PERFORM 330-MATCH-MASTER-TRAN.

IF WRITE-MASTER

PERFORM 340-WRITE-NEW-MASTER

MOVE "N" TO WRITE-MASTER-SWITCH.

310-READ-INVENTORY-TRANSACTION.

READ MNTTRAN INTO MAINTENANCE-TRANSACTION

AT END

MOVE HIGH-VALUE TO MT-ITEM-NO.

320-READ-OLD-MASTER.

READ OLDMAST INTO INVENTORY-MASTER-RECORD

AT END

MOVE HIGH-VALUE TO IM-ITEM-NO.

330-MATCH-MASTER-TRAN.

IF IM-ITEM-NO > MT-ITEM-NO

PERFORM 350-PROCESS-HI-MASTER

ELSE IF IM-ITEM-NO < MT-ITEM-NO

PERFORM 360-PROCESS-LO-MASTER

ELSE

PERFORM 370-PROCESS-MAST-TRAN-EQUAL.

340-WRITE-NEW-MASTER.

WRITE NEW-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-PROCESS-HI-MASTER.

IF ADD-RECORD

PERFORM 380-APPLY-ADD-TRANSACTION

ELSE

PERFORM 390-WRITE-ERROR-TRANSACTION.

360-PROCESS-LO-MASTER.

MOVE INVENTORY-MASTER-RECORD TO NEW-MASTER-RECORD.

SET WRITE-MASTER TO TRUE.

SET NEED-MASTER TO TRUE.

370-PROCESS-MAST-TRAN-EQUAL.

IF IM-ITEM-NO = HIGH-VALUES

SET ALL-RECORDS-PROCESSED TO TRUE

ELSE

IF DELETE-RECORD

PERFORM 400-APPLY-DELETE-TRANSACTION

ELSE

IF CHANGE-RECORD

PERFORM 410-APPLY-CHANGE-TRANSACTION

ELSE

PERFORM 390-WRITE-ERROR-TRANSACTION.

380-APPLY-ADD-TRANSACTION.

MOVE MT-ITEM-NO TO NM-ITEM-NO.

MOVE MT-ITEM-DESC TO NM-ITEM-DESC.

MOVE MT-UNIT-COST TO NM-UNIT-COST.

MOVE MT-UNIT-PRICE TO NM-UNIT-PRICE.

MOVE MT-REORDER-POINT TO NM-REORDER-POINT.

MOVE ZERO TO NM-ON-HAND

NM-ON-ORDER.

SET WRITE-MASTER TO TRUE.

SET NEED-TRANSACTION TO TRUE.

390-WRITE-ERROR-TRANSACTION.

WRITE ERROR-TRANSACTION FROM MAINTENANCE-TRANSACTION.

IF NOT ERRTRAN-SUCCESSFUL

DISPLAY "WRITE ERROR ON ERRTRAN FOR ITEM NUMBER "

MT-ITEM-NO

DISPLAY "FILE STATUS CODE IS " ERRTRAN-FILE-STATUS

SET ALL-RECORDS-PROCESSED TO TRUE

ELSE

SET NEED-TRANSACTION TO TRUE.

400-APPLY-DELETE-TRANSACTION.

SET NEED-MASTER TO TRUE.

SET NEED-TRANSACTION TO TRUE.

410-APPLY-CHANGE-TRANSACTION.

IF MT-ITEM-DESC NOT = SPACE

MOVE MT-ITEM-DESC TO IM-ITEM-DESC.

IF MT-UNIT-COST NOT = ZERO

MOVE MT-UNIT-COST TO IM-UNIT-COST.

IF MT-UNIT-PRICE NOT = ZERO

MOVE MT-UNIT-PRICE TO IM-UNIT-PRICE.

IF MT-REORDER-POINT NOT = ZERO

MOVE MT-REORDER-POINT TO IM-REORDER-POINT.

SET NEED-TRANSACTION TO TRUE.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students explore these related Databases questions