COBOL Assignment 1 ("first COBOL program")

You need to have completed this assignment by Day 4 (Wednesday February 1st 2006) at 8:30am and you will show your program to me during the tutorial of Day 4. This assignment counts 10% towards the final mark. The resulting program is re-used as a sub-program in Assignment 2.

This assignment is Project 3-1 of Murach's student workbook (page 46). It is the simplest project (using files) that I could find. It is about a common use of COBOL: report generation.


The input file is a student listing. An input test file is provided in two versions: a line-formated one and a not line-formated one. The first version is much more readable and hence will help you understand the input. Copy it on the mainframe under the name of TST1I in your PROJECTA directory (you can copy any of the two versions, the result is the same). Warning: before this copying, you must create TST1I as a file with record format "F", record length "104" and block size "104". I'll modify TST1I a bit when testing your program.
The select statement to use in your program is the following:
  select iSM-StudentMasterFile assign to TST1I
On your laptop, to use the line-formated version, you must add
  organization is line sequential
at the end of the previous statement. The COBOL record description to use is the following:

       FD iSM-StudentMasterFile.
       01 iSM.
          05 iSM-ID                       pic 9(09).
          05 iSM-Enrolment                pic x.
             88 iSM-Enrolment-isEnrolled  value "E".
             88 iSM-Enrolment-isInactive  value "I".
          05 iSM-Name                     pic x(25).
          05 iSM-DOB.
             10 iSM-DOB-Year              pic 9999.
             10 iSM-DOB-Month             pic 99.
             10 iSM-DOB-Day               pic 99.
          05 iSM-Address.
             10 iSM-Address-Street        pic x(25).
             10 iSM-Address-City          pic x(11).
             10 iSM-Address-State         pic xx.
             10 iSM-Address-ZipCode       pic 9(05).
             10 iSM-Address-ZipCodeExt    pic 9(04).
          05 iSM-Level                    pic 9.
             88 iSM-Level-isFreshman      value 1.
             88 iSM-Level-isSophomore     value 2.
             88 iSM-Level-isJunior        value 3.
             88 iSM-Level-isSenior        value 4.
          05 iSM-Major                    pic xxxx.
          05 iSM-UnitsCompleted           pic 999.
          05 iSM-TotalGradePoints         pic 999.
          05 iSM-UnitsInProgress          pic 999.



The output file is a student report (click here for the output corresponding to the above given input file). The select statement to use in your program is:
  select oSR-StudentReportFile assign to TST1O
and the COBOL record description to use is:
  FD oSR-StudentReportFile.
  01 oSR pic x(70).

On the mainframe, you must create TST1O before generating it with your program; you must create it with record format "F", record length "70" and block size "70". The report must contain one student line for each record in the student file. More precisely:
- The student ID and student name should be taken from the input file. The GPA should be calculated by dividing the total grade points in the record by the units completed (however, if the number of units completed is 0, the GPA should be 0).
- The data in the class column should be derived from the number that is stored in the class standing field in the student master record where 1 means "freshman", 2 means "sophomore", 3 means "junior" and 4 means "senior".
- The total number of students in the listing should be printed at the end of the report.
Here is the print chart to follow.



To ease your coding, you can re-use this example of a similar report generation program. You can access its requirements, an input test file for it (record length: 81) and the corresponding output file (record length: 80, not 104). The JCL scripts to compile+link and execute it are given in my document on the Marist system. You can easily re-use these scripts for this assignment by replacing the occurrences of "TEST" by "TST" and the user ID occurrences by your user ID. (To sum up, the files for this example program are: TEST1I and TEST1O which are directly under your directory PROJECTA, the cobol file TEST1 in the subdirectory COBOL, the binary file TEST1 in the subdirectory LOAD, and t generate this last file, the scripts CL and A1 in the subdirectory JCL).

This example is also provided to illustrate the coding conventions that I want you to follow in order to make your code more readable and hence easier to develop, debug, re-use and assess. These conventions have been explained during the lecture of Day 1. Here is a summary:
- variable naming conventions: 1) a variable name includes the names of the embedding structures, 2) the '-' should only be used for separating the names of the embedding structures, otherwise, the intercap style must be used, 3) after a '-', a (component) name begins by an uppercase if it refers to data and a lowercase if it refers to an action, 4) the first letter of a name begins by "i", "o", "wi" or "wo" depending on their uses: variable for input file, variable for output file, working-storage variable for inputs, working-storage variable for outputs (hence, given the first convention, in this assignment, variables should begin by "iSM", "oSR", "wiSM" or "woSR"); 5) no other abbreviation is allowed (you should use complete and explicit names);
- all COBOL keywords should be typed in the lowercase except for the section/division related keywords;
- tabulations (tabs) are forbidden,
- the program header (see the example) should be filled.


On the Marist mainframe system, your program must be named "TST1" (and be in your PROJECTA.COBOL directory). It must compile with a script named "CL" in your PROJECTA.JCL directory. It must execute correctly with a script named "A1" in your PROJECTA.JCL directory. It must be readable. For this assignment, you are not required 1) to do data validation, 2) to give comments (except in the header) nor pseudocode.

Example of penalties (given that your mark will be out of 10):
- errors at compilation: -7
- warnings at compilation (except for the "not in 'F' format" warning): -1
- ABBEND or infinite loop at execution: -5
- use of unallowed abbreviations: -0.5 for each
- disrespect of the above referred variable naming conventions: -0.5 for each
- use of tabulations: -0.5 for each
- not closing a file before exiting: -0.25 for each
- use of a subroutine for just one instruction: -0.5 for each
- subroutine longer than 25 lines: -0.25 for each
- display of traces: -0.5 for each (if you want to keep traces, use another output file which, on the mainframe, should be named "TST1T")
- header incomplete,e.g., not including your name, student id, and user id on the Marist system: -0.5
- working-storage variable not initialised: -0.5 for each (variables must often be initialized to zeros)
- duplicated code of more than 4 lines: -0.25 for each

This list of penalties is for indication only (no list of errors can be exhaustive): you are likely to make different errors and hence other penalties will apply (for example, the advices from the book should also be followed unless they contradict the above referred conventions). The above (and somewhat minimal) list of rules/conventions is here to help you and it is easy to respect them (e.g. using a tabulation or an abbreviation is a conscious act, it does not happen by accident).

When you show me your program on Day 4, please give me a printed copy of it.