Assignment 7
Copy, Sort and Merge
(100 points)
In this assignment you will use COBOL's Sort and Merge features and the Copy verb.
John Drummer, a marketing specialist, maintains contacts with many people: friends, relatives and business contacts. Among other things, he sends out many birthday cards in the course of each year. At the moment, he has 3 files of data about people and their birthdays. He needs to have them sorted and merged into one large file, and he also wants to be able to produce a list of people with birthdays in a given range of months.
Input files
File A has data set name KC02314.SUMMER09.CSCI465.HW7.A, and it is catalogued. It contains 2 header records followed by approximately 23 records having the following format:
File B has data set name KC02314.SUMMER09.CSCI465.HW7.B, and it is catalogued. It contains 3 header records followed by approximately 32 records having the following format:
File C has data set name KC02314.SUMMER09.CSCI465.HW7.C, and it is catalogued. It contain 1 header record followed by approximately 23 records having the following format:
You should use the Copy verb to obtain the record descriptions for File B and File C. The record descriptions are in members named FILEB and FILEC in a catalogued PDS with data set name KC02314.SUMMER09.CSCI465.HW7.COPYLIB.
Steps in the JCL
First, use DFSORT to sort File A in ascending order on Last Name (first key), First Name (second key) and Birthdate (3rd key). Be sure to provided the estimated file size for DFSORT.
Second, write your own JCL to use the compiler and loader for your COBOL program.
COBOL Program
Use the Sort verb to sort File B in ascending order on the same 3 keys. Use an input procedure to convert the records into the File A format. You will need to supply the first 2 digits in the year. You may assume all the years involved are after 1914. Use an output procedure to supply the Connection field, which should be 'B' for all records in File B.
Use the Sort verb to sort File C in ascending order on the same 3 fields. You will need to use an input procedure to convert the date to the format used in File A. (In theory, this could truncate some names. Ignore this possibility.)
Now use COBOL's Merge verb to combine the 3 files using the same 3 keys. Use an output procedure to eliminate duplicates. If two or more records have the same keys but have different Connections, combine them:
Extract all records for which the Birthdates are in the desired months (of any year) and write them into a separate file. (See the Programming Notes section.) You should count the extracted records.
Print the contents of the merged file in a neat report. The report should have a page heading including the date and a page number, as well as column headings. Double-space between detail lines. Center your output on the page. All dates should be spelled out using the name of the month, as in "23 August 2001" or "14 May 1997". (Put these together with the String statement.) The Connection field should be spelled out as "Relative", "Business", or "Friend". Print no more than 50 lines per page.
Last, sort the contents of the extract file in ascending order by Birthdate and use an output procedure to print the results in a second neat report. You can use the same format but use a different page heading. Indicate somewhere at the top of the page what months were used in extracting records. There is no need to write the sorted records from the extract file into a separate file.
Programming Notes