Science Fiction by Mail
|Time to complete||This is a tough one. Allow 6 hours continuous.|
|Program Download||SFbyMail.Cbl is a model answer. Don't look at this until you have made your own attempt at the program.|
See the Data Files with spaces inserted for
See the Data Files with spaces inserted for
For the actual input files
Orders.Dat is the the sequential orders file
The conversion program is required because Indexed files are not standard ASCII files and cannot be viewed or edited in a standard text application like Notepad.
If you want to view that contents of the indexed file you can convert it back to a sequential ASCII file using the program BSF2Seq.Cbl.
In a large software system, where a number of programmers are working on different subprograms, some programmers will finish before others. Programmers who have completed their work will want to test their programs. But if a completed program either CALLs, or is CALLed by, other programs, the programmer will have to wait for the other programs to be completed before any testing can be done. Obviously this not an acceptable state of affairs. The problem is usually solved by means of "stubs" and "drivers".
A"stub" is a small program that pretends to be a Called program. The stub, of course, does not provide anything like the functionality that the final subprogram will provide. It contains just enough code to allow the programmer to verify that his program is actually calling the subprogram and is passing and receiving the parameter values correctly. The stub might do this by providing a limited set of responses to a limited set of inputs or it might interrogate the user to allow him to provide a response to any input parameters.
A "driver" is the reverse of this. It is a small program that pretends to be the CALLing program. It contains just enough code to call the subprogram and to pass and receive the parameter values. Just as with the stub, the driver program might generate a very limited set of parameter values or might interrogate the user to obtain input parameters and might display the value of any output parameters.
Science Fiction by Mail calls two programs that are supposed to be written by others. Both of these programs have been provided as "stubs".
GetPostage.Cbl is the stub standing in for the real GetPostage subprogram
GetCustomerAddress.Cbl is the stub standing in for the real GetCustomerAddress.Cbl.
|Major Constructs||CALL, subprograms, Sequential files, Indexed files, READ, WRITE, REWRITE, COMPUTE, UNSTRING|
Science Fiction by Mail is a company which sells Science Fiction and Fantasy books through the Internet. Customers view the book catalogues and place orders by connecting to the company’s web site. When an order is placed, an Order-Number is assigned, and the details of the order are written to an Orders file (ORDERS.DAT). Only already registered customers can place an order.
At the end of the day, the Orders file is processed, applying it to the Book Stock file and producing a Processed Orders file. The Processed Orders file is used by other programs (not required for this exam) to bill the customers and to produce invoices and address labels.
For each book title required in an order, the Book Stock File must be updated by subtracting the Qty-Required from the Qty-In-Stock. When a book request cannot be filled because there is insufficient stock, this must be indicated by writing zeros to the Quantity-Required field of the Processed-Orders record. The Book Stock file must not be updated.
A program is required to apply the Orders file to the Book Stock file
and produce the Processed Orders file.
The Orders File (Sequential)
The Orders file is an unsorted, validated, sequential file. Each record may contain an order for up to 10 different book titles. Where all ten titles are not requested the rest of the record is space filled.
The Book-Details are held in a ten element table. Each element consists of the Book-Id and the Qty-Required. The record description is as follows;
In the following example record spaces have been inserted for convenience.
The order number in this record is 1234567, the Customer-Id is C1234 and 3 different titles have been requested. One copy of B1234, three copies of B2345 and two copies of B3456 have been ordered.
Book Stock File (Indexed)
The Book Stock file holds details of the company’s stock of books. It is an indexed file containing records with the following description;
Processed Orders File (Sequential)
The Processed Orders file is a sequential file. For each book title requested in the Orders File, a record must be created in the Processed Orders File. The record description is as follows;
The Copy-Postage may be obtained by calling two external subprograms. These subprograms have already been written and you may assume that they will be present in the same directory where your program is run.
Cust-Address contains the customer address. The parts of the customer address are separated from one another by commas. The last item in the customer address is a two character Country-Code. This code must be extracted from the customer address and then used to obtain the Copy-Postage (cost of posting one book to the customer).
Example address = 13 Winchester Drive, Castletroy, Limerick, Ireland, IE
This COBOL project specification is the copyright property of Michael Coughlan. You have permission to use this material for your own personal use but you may not reproduce it in any published work without written permission from the author.