Lab2

=Lab 2 consists of four parts.=

Lab 2A:
Create a program that reads a number from user input (a 5 digit number) and a name (15 digit string) adds one to the number and then displays that number to the screen along with the name. Create a loop so that the "add one" paragraph is executed 10 times (i.e. read a string and a number 10 times). The program should structure the number and name as an account record. Remember this needs to be run via TSO (but use JCL to compile & link the program).
 * Create an "Add one" COBOL program**


 * //Hints://**
 * //Remember to use the Dataset Copy utility to copy your "Hello" COBOL, JCL, and LOAD datasets from LAB1C//
 * //Variables are only coded in the WORKING-STORAGE SECTION in the DATA DIVISION//
 * //Check compiler output in SDSF ("SD" from the primary options menu) - fix compile time errors as needed (when in doubt...Google it!)//
 * //Remember you will need to actually run your program from the command line://
 * //Option 6 from the Primary Options menu//
 * //Then enter each of the following commands://
 * //ALLOCATE DDNAME(SYSOUT) DSNAME(*)//
 * //ALLOCATE DDNAME(SYSIN) DSNAME (*)//
 * //CALL 'KC#####.LAB2A.LOAD(ADDONE)' - you will need to update this command with the LOAD dataset and member for your program//

Lab 2B:
Create a program that reads a sequential data set (that contains a 5 digit number for the account number and a 5 digit balance). Subtract ten from the balance and then write the new balance out in the record (i.e. overwrite the data in the dataset). The balance should not be allowed to be made negative (i.e. if the balance is less than 10, set balance to 0). This needs to be done for all records in the dataset. Of course, prior to running this program, one needs to create the dataset, and then initialize the data in the dataset (e.g. create a sequential data set and using the ISPF editor, enter the records).
 * Subtract 10 from the balance**

The JCL to compile, link and run the program is similar to the "Hello world" JCL, except one needs a DD (data definition) for the sequential dataset in the JCL. The line of JCL (assuming the name of the dataset is "KC02124.LAB2B.ACCT", and the logical file name used in your program is "ACCT") would be: code //GO.ACCT DD DSN=KC02124.LAB2B.ACCT, DISP=SHR code
 * What do you need to create for Lab 2B:**

Create the following datasets: >>> 9999911500 >>> 1010100000
 * COBOL source (copy from previous lab)
 * LOAD (copy from previous lab)
 * JCL (copy from previous lab)
 * INPUT (allocate a new sequential dataset)
 * 10 byte record
 * 5 byte account number
 * 5 byte balance
 * 3.2 ALOCATE menu
 * RECORD LENGTH = 10
 * BLOCK SIZE = 10
 * Edit and type ‘NUM OFF’ command
 * Type data in the dataset, sample records:
 * 1234500090

Lab 2C:

 * "Read a Sequential dataset and create indexed (VSAM) dataset**"

Step 1: Create an input dataset (sequential) for your program. The fields of the record consist of:

 * Name
 * First name = character string of length 15
 * Last name = character string of length 15
 * Address
 * Street Address = character string of length 15
 * City: character string of length 10
 * State: character string of length 2
 * Zip code: digits in the form of xxxxx
 * SSN: digits in the form xxxxxxxxx (remember, you can store the data this way, but when its displayed you can format it: xxx-xx-xxxx)
 * Credit limit: dollar amount in with 7 digits - two after the decimal point (but should be displayed as: $xx,yyy.zz if needed)

**Step 1.5: create the indexed (VSAM data set):**
The indexed data set has all the fields of the input (sequential) data set, plus an available balance (7 digits, 2 after the decimal), initially set to the same value of the credit limit.

**Step 2:** Write a program to update/add records to a master indexed dataset:

 * Create a "customer account master file".
 * Code the program such that:
 * First, the program opens the "input data file" (sequential data).
 * Then, read the first record in the dataset. For this record, look up SSN in "account master" (indexed) datafile:
 * If found, update the information from the data record
 * If not found, create a new record in the account master file and store the information, using the SSN from the input file.
 * Repeat reading records until there are no more input records.

Step 3: Write a second program to display the fields in the account master VSAM dataset.
The program should open the "account master" indexed dataset. Then, for each record, display:
 * Name
 * Address (including street, city, zip)
 * SSN
 * Credit Limit
 * Available balance

You can create the VSAM (indexed) dataset two ways: write a JCL (job) to build the dataset, or use the VSAM utility under option 3.2.
 * Creating a VSAM dataset:**

The JCL to create a VSAM file is shown below (the JCL creates a VSAM file with a record of 71 bytes, the KEY is 11 bytes, starting at Byte 0). code 000100 //CREATEKS JOB

000110 //STEP1 EXEC PGM=IDCAMS

000200 //SYSPRINT DD SYSOUT=*

000300 //SYSIN DD *

000400 DEFINE CLUSTER (NAME(KC0xxxx.DATATEST.AcctM) -

000500 RECORDS(15 15) -

000600 RECORDSIZE(71 71) -

000800 KEYS(11 0) -

000900 INDEXED) -

001000 DATA (NAME(KC0xxxx.DATATEST.AcctM.DAT)) -

001200 INDEX (NAME(KC0xxxx.DATATEST.AcctM.IDX))

001300 /*

001400 //* code

The JCL to define the "DD" for the VSAM defined above, would look like: code //GO.ACCTMAST DD DSN='KC02170.DATATEST.AcctM',DISP=SHR code



Lab 2D (extra credit, not required)

 * Use sorted batch files to create accounts**

Create a program, similar to Lab 2C, but with this program: > > The following JCL can be used to compile a program (named ACCTMAST) and put it into a library (for use by other programs) code 000100 //MYACCTM JOB
 * use a copybook to define the VSAM file definition
 * to implement the adding the "input file" to the "customer master file", do not use a VSAM index, but rather, sort the "input file" and then go through the customer master file sequentially in conjunction with the "input file" -- and adding the new customers as apprioriate.
 * Use a similar construct to the code in "Add One" to ensure you create unique customer ids.

000400 //STEP1 EXEC PROC=IGYWC,PARM.COBOL='LIB,OBJECT,XREF,FLAG(I,E)'

001110 //COBOL.SYSIN DD DSN=KC02170.MINI.COBOL(ACCTMAST),DISP=SHR

001114 //*

001115 //* DEFINE WHERE TO FIND THE COPYBOOKS

001116 //COBOL.SYSLIB DD DSN=KC02170.MINI.COPYLIB,DISP=SHR

001117 //*

001118 //* DEFINE WHERE THE OBJECT WILL WILL GO

001119 //COBOL.SYSLIN DD DSN=KC02170.MINI.OBJLIB(ACCTMAST),DISP=SHR code

The following JCL has statements to enable you to use copybooks (in copylib) and reference other programs compiled as libraries for this main program (in objlib) code 000100 //MYMAIN JOB

000400 //STEP1 EXEC PROC=IGYWCLG,PARM.COBOL='LIB,OBJECT,XREF,FLAG(I,E)'

001110 //COBOL.SYSIN DD DSN=KCxxxxx.MINI.COBOL(MAIN),DISP=SHR

001111 //*

001112 //* DEFINE WHERE TO FIND THE COPYBOOKS

001113 //COBOL.SYSLIB DD DSN=KCxxxx.MINI.COPYLIB,DISP=SHR

001114 //*

001115 //* WHERE TO PUT OUTPUT EXECUTABLE

001120 //LKED.SYSLMOD DD DSN=KCxxxx.MINI.LOAD(MAIN),DISP=SHR

001121 //*

001122 //* DEFINE WHERE THE OTHER OBJECT FILES ARE LOCATED

001123 //LKED.SYSLIB DD

001124 // DD DSN=KCxxxx.MINI.OBJLIB,DISP=SHR

001125 //*

001126 //* DEFINE THE INPUT/UPTPUT DATASET

001127 //GO.NXTACCN DD DSN=KCxxxx.DATA.NXTACCN,DISP=SHR

001129 //GO.ACCTMAST DD DSN='KCxxxx.DATATEST.AcctM',DISP=SHR

001131 //GO.NEWACCTS DD DSN=KCxxxx.DATA.NEWACCTS,DISP=SHR

001140 //GO.SYSOUT DD SYSOUT=* code