New Jersey Institute of Technology (NJIT)
Computer and Information Science Department (CIS)
CIS365-001:
File Structures and Management, Fall 1999
Professor: Michael
Bieber
Monday, September 27, 1999 at the start of class
(but don't skip class to finish this assignment!)
To continue writing simple COBOL programs, and to prepare for future homework assignments
Read Chapters 1-4 in the Stern & Stern text.
* (Part 1 was in homework 2a)
Write a COBOL program that will create a transaction file to update the book file. The following transactions are possible:
|
I |
insert a new book record |
|
D |
delete an existing book record |
|
MP |
modify the price of a book on an existing record |
|
MT |
modify the book title on an existing record |
The program will ask the user to transaction data from the keyboard for testing purposes. The transaction file contains all books the store offers. Input the following data:
Book ID Code Other Information... 2-222-22222-2 D 2-222-33333-3 I Information Systems V2 Alter, Steven 1996 Bus 049.95 2-222-44444-4 D 3-333-33333-3 I The Fellowship of the Ring Tolkien, J. R. R. 1965 Fan 005.95 5-555-55555-5 MP 007.95 6-666-66666-6 MT Beyond the Safe Zone 7-777-00000-0 I Encounter with Tiber Aldrin, Buzz 1996 SciFi 012.95 7-777-77777-7 D 8-888-88888-8 I Taxes for Dummies Tyson, Eric 1996 Tax 014.99 9-000-00000-0 MT COBOL for Dummies
Your transaction file will have the following record structure in the FILE SECTION:
01 transaction-record-out. 05 tro-isbn PIC X(13). 05 tro-code PIC X(02). 05 tro-info PIC X(65).
The contents of the {tro-info} field will have different content based on whether the transaction code is I, D, MP or MT.
You will actually build the contents of the {tro-info} field in your WORKING-STORAGE SECTION and MOVE it to the {transaction-record-out}. This is because the {tro-info} field will have different content based on whether the transaction code is I, D, MP or MT.
For "I" it will be all the fields of the master file record (except the ISBN, which already is in the {transaction-record-out}. You should build this in the WORKING-STORAGE SECTION using the following structure:
01 ws-insert-record-fields. 05 title-user PIC X(30). 05 author-user PIC X(20). 05 year-user PIC 9999. 05 category-user PIC X(6). 05 price-user PIC 999V99.
Then you would use the following line in your PROCEDURE DIVISION:
For "D" make the {tro-info} field blank:
For "MP" and "MT" move the new price or title info to the {tro-info} field. It's OK that the {tro-info} field is alphanumeric.
Use COBOL's EVALUATE statement to decide how to fill in {tro-info}. The Stern & Stern text describes EVALUATE on pages 146-147.
If you have any trouble at all, use the COBOL debugging features of stepping through your program and watching data values to figure out what is wrong. Please do not ask for help with your program's logic until you have done this and thoroughly examined your program!
Write a COBOL program that will read each record of your master file from Part 1 and DISPLAY each variable to the screen.
Note: Now your file will be an input file, not an output file as with Parts 1 and 2. Use "IN" instead of "OUT" in your ENVIRONMENT DIVISION. Use "in" as part of your file and record names instead of "out".
Write a COBOL program that will read each record of your transaction file from Part 2 and DISPLAY each variable to the screen.
DISPLAY the {tri-info} field differently based on whether it belongs to an insert, delete, modify price or modify title transaction. Use COBOL's EVALUATE statement in your PROCEDURE DIVISION to handle each kind of transaction separately.
Note: Again, here your file will be an input file, not an output file. Use "IN" instead of "OUT" in your ENVIRONMENT DIVISION. Use "in" as part of your file name, "transaction-record-in" as your record name, and "tri-" as the start of the record field names instead of "tro-".
This page: http://www.cis.njit.edu/~bieber/CIS365F99/hw2b.html