Pascal Memorial Library
Royalty Payments Report Program

Time to complete Allow 4-6 hours continuous.
Program Download LibRoyaltyRpt.Cbl is a model answer. Don't look at this until you have made your own attempt at the program.
Example Output

Royalties.Rpt is the report produced by processing the two indexed files.

Example Input

AuthorIn.Dat is a sequential version of the indexed Authors file. This file can be converted into the indexed Authors.Dat file by using the program Seq2Authors.Cbl

BooksIn.Dat is a sequential version of the indexed Books file. This file can be converted into the indexed file Books.Dat by using the program Seq2Books.Cbl.

Major Constructs Indexed Files, Print Files, READ..NEXT RECORD, READ..KEY IS, START, REWRITE, WRITE, MULTIPLY, SET

Introduction

Each time a book is borrowed, the Pascal Memorial Library pays the author a small sum of money as royalty.  Because the sum owed for each "borrowing" is very small, royalties are only paid once every quarter.  Royalties are paid to authors through their agents.  Only one cheque per quarter is sent to each agent but to allow him to pay his authors the correct amount, a breakdown of the royalties owed to each author is included with the cheque.

A report is required which;

    • Shows the amount to be sent to each agent.
    • Shows the breakdown of the agent payment into author payments.
    • Shows the breakdown of each author payment into royalty payments per book.

The report must be printed in agent name sequence.  The sequence of authors within each agent and of books within each author does not matter.  The print specification for the report is on the last page.

Files

All the data required to produce the Royalty Payment Report is contained in two indexed files.

The indexed file Books.Dat has the following record description;-

Field

KeyType

Type

Length

Value

Book-Number

Primary

9

7

1-9999999

Book-Name

-

X

25

-

Author-Number

Alt with Duplicates

9

7

1-9999999

Royalty-Rate

-

9

3

0.001-0.999

Quarter-Borrowings

-

9

3

0-999

 

The indexed file Author.Dat has the following record description;-

Field

KeyType

Type

Length

Value

Author-Number

Primary

9

7

1-9999999

Author-Name

-

X

25

-

Agent-Name

Alt with Duplicates

X

25

-

 

Processing

Some fields required in the report do not appear in either of the indexed files and must be calculated.  The following describes these fields and how to calculate them;

Book-Royalty contains the royalty to be paid for a book for the quarter.  It is obtained by multiplying Quarter-Borrowings by Royalty-Rate.  It is a numeric field with up to three places before the decimal point and two places after.

Quarter-Author-Borrows contains the sum of Quarter-Borrowings for all of an authors books on loan in the library.  It is a numeric field up to four digits long.

Author-Royalties is the sum of an author's Book-Royaltys. It is a numeric field with up to four places before the decimal point and two after.

Agent-Payment is the sum of an agent's Author-Royalties.  It is a numeric field with up to six places before the decimal point and two after it.

In addition to producing the report the program must perform a small update on the Quarter-Borrowings field of the Books file.  When all the calculations involving the Quarter-Borrowings field have been done, it must be set to zero so that the borrowings for the new quarter may be accumulated.

 

Print Specification

Line 2-5 Headings; to be printed at the top of the report only.
Line 7
Cols 1-25 Agent-Name is printed once for each new agent.
Cols 28-52 Author-Name is printed once for each new author.
Cols 55-79 Book-Name.
Cols 84-86  Quarter-Borrowings for the book.  It is a numeric field zero suppressed except for the last digit.
Cols 91-97 Book-Royalty field.  It is numeric with a floating dollar sign and a decimal point.
Lines 8-13 Same as line 7 but the agent and author names have been suppressed.
Lines 15-16

Printed when all the book details for an author have been printed. Quarter Borrowings contains the accumulated quarter borrowings for an author.  It is a numeric field with zero suppression and comma insertion.

Royalties is the accumulated Book-Royaltys for an author.  It is a numeric field with a floating dollar sign, decimal point and comma insertion.

Line27 Printed when all the author details for an agent have been printed. Agent-Payment contains the accumulated royalties to be paid to an agent's authors.  This field is numeric with a floating dollar sign, decimal point and comma insertion.

 

Notes:  There is no need to allow for page breaks. 

 


Click for full size version




Copyright Notice

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.