CSCI 465 Assignment 3
Basic COBOL
(50 points)
This assignment is in two parts.
Part A (20 points)
For this part of the assignment, the text of a COBOL program is provided for you, along with the job control language (JCL) needed to submit that program to the IBM S/390 computer for execution.
Your task is to type this text, save it in a file, submit the file for execution, fetch the output, check it to see if it is correct, make any necessary changes to the file and resubmit it (as often as needed until it is correct), and finally print the output file. You will turn in the final printed copy. (Note: You may print a copy even before it is correct whenever you need a printed copy for debugging purposes).
Learning the things in the preceding paragraph is primarily a do-it-yourself project. You should already be familiar with submitting assembler programs to the mainframe from CSCI 360 and the Assignments 1 and 2, and the process is basically identical for COBOL programs.
Output from Assignment 3, Part A will be a line containing the date and time, plus data about one course, as follows:
Date: 2009/05/19 Time: 15:18:20:69
CSCI 465 External Data Structures
Credit Hours: 4
Prerequisites: CSCI 360
If you do not get this output, either you made a typo or you typed something in the wrong column. Both the JCL reader and the COBOL compiler are very fussy about which columns things are typed in. JCL lines (beginning with //) start in column 1. Documentation lines (beginning with a *) start in column 7. "Identification Division" starts in column 8. "Select..." starts in column 12. "FD" starts in column 8 and is followed by 2 spaces, so that "Input-File" starts in column 12. Type the program exactly as given. Do not try to improve it in any way.
The program you turn in should have correct output, and both return codes should be 00. The return codes are in approximately column 43 of line 10 of the first printed page. You should see return codes of 00 for both the COBOL step and the GO step.
When your program is working, print and hand in the "JOB0nnnn" file, rather than the "JOBnnnnn.txt" file.
JCL and COBOL Program
Note to students: You are expected to type (or cut and paste) the text of the COBOL program below exactly as given, including the documentation. In the first two lines of the text, you must substitute your own Z number, name, and bin number. Use the last three digits of your Z number as your bin number. You may learn more if you do not cut and paste.
//KC0nnnnA JOB ,'your name',MSGCLASS=U
//STEP1 EXEC PROC=IGYWCG,PARM.COBOL='FLAG(I,I),APOST,TEST(STMT)'
//*
//COBOL.SYSIN DD *
***************************************************************
* Program Name: PROG3A
*
* Function: To print data about one computer science
* course.
*
* Input: A file containing one course record.
*
* Output: Three detail lines are printed from the data
* on the input record.
*
* Notes: None
***************************************************************
Identification Division.
Program-Id. PROG3A.
Environment Division.
Input-Output Section.
File-Control.
Select Input-File Assign to COURSE.
Select Print-File Assign to PRINTER.
Eject
Data Division.
File Section.
***************************************************************
* The Input-File contains one 80-character customer record.
* Each record contains the course number, course title,
* credit hours, and prerequisites.
***************************************************************
FD Input-File
Recording Mode is F.
01 Input-Record.
05 In-Course-Number Pic X(8).
05 In-Course-Title Pic X(35).
05 In-Credit-Hours Pic 9.
05 In-Prerequisites Pic X(35).
05 Pic X.
***************************************************************
* The Print-File holds the output. Print-Record is written
* from detail lines defined in Working-Storage.
***************************************************************
FD Print-File
Label Records are Omitted
Recording Mode is F.
01 Print-Record Pic X(132).
Eject
Working-Storage Section.
***************************************************************
* Variable Dictionary *
* *
* System-Date-And-Time Current system date and time. *
* *
* Detail-Line-One Course number and title. *
* *
* Detail-Line-Two Credit hours. *
* *
* Detail-Line-Three Prerequisites. *
* *
***************************************************************
01 System-Date-And-Time.
05 Pic X(45) Value Spaces.
05 Pic X(9) Value 'Date: 20'.
05 Sys-Date Pic 99/99/99.
05 Pic X(5) Value Space.
05 Pic X(7) Value 'Time: '.
05 Sys-Time Pic 99B99B99B99.
05 Pic X(48) Value Spaces.
01 Detail-Line-One.
05 Pic X(45) Value Spaces.
05 D1-Course-Number Pic X(8).
05 Pic X(8) Value Spaces.
05 D1-Course-Title Pic X(35).
05 Pic X(37) Value Spaces.
01 Detail-Line-Two.
05 Pic X(45) Value Spaces.
05 Pic X(16)
Value 'Credit Hours:'.
05 D2-Credit-Hours Pic X.
05 Pic X(71) Value Spaces.
01 Detail-Line-Three.
05 Pic X(45) Value Spaces.
05 Pic X(16)
Value 'Prerequisites:'.
05 D3-Prerequisites Pic X(35).
05 Pic X(37) Value Spaces.
Eject
Procedure Division.
***************************************************************
* 000-Main obtains the system date and time, then calls a
* subroutine to print it. It reads the input record, then
* calls a subroutine to print the detail lines.
***************************************************************
000-Main.
Open Input Input-File
Output Print-File.
Accept Sys-Date from Date.
Accept Sys-Time from Time.
Inspect Sys-Time Replacing all ' ' by ':'.
Perform 100-Print-Header.
Read Input-File.
Perform 200-Process-Record.
Close Input-File
Print-File.
Stop Run.
Eject
***************************************************************
* 100-Print-Header just prints the system date and time.
***************************************************************
100-Print-Header.
Write Print-Record from System-Date-And-Time
After Advancing Page.
Eject
***************************************************************
* 200-Process-Record fills in each detail line (with
* appropriate data from the input record) and writes it.
***************************************************************
200-Process-Record.
Move In-Course-Number to D1-Course-Number.
Move In-Course-Title to D1-Course-Title.
Write Print-Record from Detail-Line-One
After Advancing 2 Lines.
Move In-Credit-Hours to D2-Credit-Hours.
Write Print-Record from Detail-Line-Two.
Move In-Prerequisites to D3-Prerequisites.
Write Print-Record from Detail-Line-Three.
/*
//GO.COURSE DD *
CSCI 465External Data Structures 4CSCI 360
/*
//GO.PRINTER DD SYSOUT=*
//
Note to students: The input record follows the //GO.COURSE line and must be typed exactly as shown. Since the course title does not take up all 35 character positions allotted for it in the FD, blanks are used to fill in the remaining character positions. The 4 is in column 44.
Part B (30 points)
In this part of the assignment, you will need to modify the program from Part A to expand it slightly. Instead of reading just one line, it will read a file containing several lines. For each line, it will print output just like what was printed in Part A. We also want to add up the total number of hours.
There are a number of steps in modifying the program. You may need to read about some of the details in the COBOL textbook if they have not yet been covered in class. None of this is difficult.
//GO.COURSE DD DSN=KC02314.SUMMER09.CSCI465.HW3,DISP=SHR
Total Hours: 16
If all this works correctly, you should be reading the data and printing three lines about each course, and you should print a line at the end giving the total number of hours.
You will need to run both programs and turn in the printouts. Be sure to put your name and other information on each.