Exercises: Development Environment Setup
Exercise 2.1: Environment Verification
Set up at least one COBOL development environment (GnuCOBOL, Hercules/TK5, or IBM Z Xplore) and verify it by compiling and running the ENV-CHECK program from Section 2.2. Submit a screenshot or transcript of the output.
Exercise 2.2: VS Code Configuration
Install VS Code with a COBOL extension and configure it according to Section 2.5. Create a COBOL program file and verify the following:
a) Syntax highlighting is active (keywords appear in color) b) Column rulers are visible at the correct positions (7, 8, 12, 72) c) The file is recognized as COBOL (check the language mode in the bottom status bar)
Take a screenshot showing all three verifications.
Exercise 2.3: JCL Analysis
Given the following JCL, answer the questions below:
//CLMPROC JOB (MEDCLM),'CLAIMS BATCH',CLASS=A,
// MSGCLASS=X,MSGLEVEL=(1,1),
// NOTIFY=&SYSUID
//STEP1 EXEC PGM=CLMVALID
//STEPLIB DD DSN=PROD.LOADLIB,DISP=SHR
//CLMIN DD DSN=PROD.CLAIMS.DAILY,DISP=SHR
//CLMOUT DD DSN=PROD.CLAIMS.VALID,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(20,5),RLSE),
// DCB=(RECFM=FB,LRECL=500,BLKSIZE=0)
//ERRFILE DD DSN=PROD.CLAIMS.ERRORS,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(5,2),RLSE),
// DCB=(RECFM=FB,LRECL=500,BLKSIZE=0)
//SYSOUT DD SYSOUT=*
//STEP2 EXEC PGM=CLMADJUD,COND=(4,LT,STEP1)
//STEPLIB DD DSN=PROD.LOADLIB,DISP=SHR
//CLMIN DD DSN=PROD.CLAIMS.VALID,DISP=SHR
//CLMPAID DD DSN=PROD.CLAIMS.PAID,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(20,5),RLSE),
// DCB=(RECFM=FB,LRECL=500,BLKSIZE=0)
//SYSOUT DD SYSOUT=*
a) What is the job name? What system (from our running examples) does this likely belong to?
b) How many steps does the job have? What programs do they execute?
c) What does COND=(4,LT,STEP1) mean? Under what condition will STEP2 be skipped?
d) What SELECT/ASSIGN statements would the COBOL program CLMVALID need for this JCL?
e) What is the record length of the claims files? What does RECFM=FB mean?
Exercise 2.4: GnuCOBOL Compiler Exploration
Using GnuCOBOL, compile the ACCT-SUMMARY program from Section 2.7 with each of the following flag combinations and observe the differences:
a) cobc -x ACCT-SUMMARY.cbl (basic compilation)
b) cobc -x -Wall ACCT-SUMMARY.cbl (all warnings)
c) cobc -x -Wall -debug ACCT-SUMMARY.cbl (with debug checks)
d) cobc -x -Wall -t ACCT-SUMMARY.lst ACCT-SUMMARY.cbl (with listing)
Open the .lst listing file and identify: the data map (showing field positions and sizes), the cross-reference listing, and any compiler messages.
Exercise 2.5: Build Script
If using GnuCOBOL, create the directory structure recommended in Section 2.8 and write a build script (bash or batch) that:
a) Compiles a specified COBOL program from the source/ directory
b) Places the executable in the bin/ directory
c) Generates a listing in the listings/ directory
d) Searches the copybooks/ directory for any COPY members
e) Displays a success or failure message
Test your build script with the ACCT-SUMMARY program.
Exercise 2.6: ABEND Investigation
Write a COBOL program that intentionally triggers each of the following error conditions (compile and run separately for each):
a) A data exception (S0C7 equivalent): Move spaces to a numeric field, then attempt arithmetic on it. b) A subscript out of range: Define a table with 5 elements and attempt to access element 10. c) A division by zero: DIVIDE a number by a field containing zero.
For each case, document: the COBOL code that causes the error, the error message or behavior you observe (which may differ between GnuCOBOL and z/OS), and how you would fix the code defensively.
Exercise 2.7: Environment Comparison Essay
Write a 300-word comparison of two of the three development environment options (GnuCOBOL, Hercules/TK5, IBM Z Xplore). Address: ease of setup, authenticity of the mainframe experience, suitability for this textbook, and any limitations you encountered.
Exercise 2.8: The Complete Cycle
Write a COBOL program called GRADE-CALC that:
a) Defines working storage for a student name (PIC X(30)) and three exam scores (PIC 999) b) Uses ACCEPT to get the student name and three scores from the user c) Calculates the average score (COMPUTE, rounding to nearest integer) d) Determines a letter grade (A=90+, B=80-89, C=70-79, D=60-69, F below 60) using EVALUATE e) Displays a formatted "report card" with the student name, individual scores, average, and letter grade
Compile and run the program. Test with at least three different sets of inputs, including edge cases (scores of 0, 100, and exactly on grade boundaries).