Beruflich Dokumente
Kultur Dokumente
COMPANY CONFIDENTIAL
COPYRIGHT NOTICE
All ideas and information contained in this document are the intellectual property of Education and Research Department, Infosys Technologies Limited. This document is not for general distribution and is meant for use only for the person they are specifically issued to. This document shall not be loaned to anyone, within or outside Infosys, including its customers. Copying or unauthorized distribution of this document, in any form or means including electronic, mechanical, photocopying or otherwise is illegal.
Education and Research Department Infosys Technologies Limited Electronic City Hosur Road Bangalore - 561 229, India. Tel: 91 80 852 0261-270 Fax: 91 80 852 0362 www.infy.com mailto:E&R@infy.com
ER/CORP/CRS/LA01/007
Version No :3.0
Table of Contents
Contents
COPYRIGHT NOTICE ....................................................................................................... I COPYRIGHT NOTICE ...................................................................................................... II DOCUMENT REVISION HISTORY ......................................................................................... I CONTENTS .................................................................................................................. II CONTEXT ................................................................................................................... 1 DAY 1 ASSIGNMENTS ..................................................................................................... 1 ASSIGNMENT 1: WRITING A COBOL CODE IN THE CODING SHEET, EXECUTING AND VIEWING THE OUTPUT IN SPOOL ....... 1 ASSIGNMENT 2: DEBUGGING A COBOL PROGRAM .......................................................................... 2 ASSIGNMENT 3: UNDERSTANDING COBOL CODING STANDARDS............................................................. 2 ASSIGNMENT 4: UNDERSTANDING ARITHMETIC STATEMENTS IN COBOL .................................................... 3 ASSIGNMENT 5: UNDERSTANDING EDITED PICTURE CLAUSES AND MOVE VERB ............................................. 4 ASSIGNMENT 6: UNDERSTANDING THE LEGAL MOVES IN COBOL ......................................................... 5 ASSIGNMENT 7: EXERCISES FOR SELF REVIEW ............................................................................... 6 DAY 2 ASSIGNMENTS ..................................................................................................... 6 ASSIGNMENT 1: DEMONSTRATION OF ON SIZE ERROR CLAUSE ............................................................ 6 ASSIGNMENT 2: UNDERSTANDING PERFORM..UNTIL VERB ............................................................. 9 ASSIGNMENT 3: GENERATION OF PAY SLIP OF AN EMPLOYEE USING ARITHMETIC VERBS, ROUNDED AND ON SIZE ERROR CLAUSES .................................................................................................................. 12 ASSIGNMENT 4: GENERATING GRADE SHEETS OF STUDENTS USING PERFORM VERBS AND IF..THENELSE ............ 13 ASSIGNMENT 5: USING PERFORM.UNTIL VERB TO ACCEPT CHOICE FROM USER AND DISPLAY THE OUTPUT ............ 15 ASSIGNMENT 6: USING PERFORM.VARYING TO GENERATE N ELEMENTS OF FIBONACCI SERIES ..................... 15 ASSIGNMENT 7: EXERCISES FOR SELF REVIEW ............................................................................. 16 DAY 3 ASSIGNMENTS ................................................................................................... 16 ASSIGNMENT 1: CREATION OF PS FILE AND UNDERSTANDING THE READ OPERATION OF A PS FILE ......................... ASSIGNMENT 2: UNDERSTANDING WRITE OPERATION OF A PS FILE ........................................................ ASSIGNMENT 3: APPENDING RECORDS TO A PS FILE ....................................................................... ASSIGNMENT 4: UPDATING RECORDS IN A PS FILE......................................................................... ASSIGNMENT 5: UNDERSTANDING SEQUENTIAL FILE MANIPULATIONS ...................................................... ASSIGNMENT 6: EXERCISES FOR SELF REVIEW ............................................................................. 16 17 18 18 19 20
DAY 4 ASSIGNMENTS ................................................................................................... 21 ASSIGNMENT 1: UNDERSTANDING READ AND WRITE OPERATIONS IN A VSAM KSDS FILE ................................ ASSIGNMENT 2: UNDERSTANDING THE VSAM KSDS FILE MANIPULATIONS ................................................ ASSIGNMENT 3: UNDERSTANDING COPY VERB ........................................................................... ASSIGNMENT 4 : UNDERSTANDING CALL VERB ........................................................................... ASSIGNMENT 5: CREATION OF MODULAR COBOL PROGRAMS ............................................................. ASSIGNMENT 6: UNDERSTANDING VSAM KSDS FILE AND PS FILE MANIPULATIONS ........................................ ASSIGNMENT 7: CREATION OF ALTERNATE INDEX FOR A VSAM KSDS FILE ................................................ ASSIGNMENT 8: EXERCISES FOR SELF REVIEW ............................................................................. 21 26 27 31 34 35 35 36
ER/CORP/CRS/LA01/007
Version No.3.0
ii
Table of Contents
DAY 5 ASSIGNMENTS ................................................................................................... 36 ASSIGNMENT 1: DEMONSTRATION OF ONE DIMENSIONAL ARRAY........................................................... ASSIGNMENT 2: DEMONSTRATION OF STRING AND UNSTRING VERB .................................................... ASSIGNMENT 3: DEMONSTRATION OF INSPECT VERB .................................................................... ASSIGNMENT 4: DEMONSTRATION OF SEARCH ALL VERB ................................................................ ASSIGNMENT 5: DEMONSTRATION OF REDEFINES AND RENAMES CLAUSES ............................................. ASSIGNMENT 6: UNDERSTANDING STRING HANDLING VERBS .............................................................. ASSIGNMENT 7: EXERCISES FOR SELF REVIEW ............................................................................. 36 38 40 41 45 48 49
ER/CORP/CRS/LA01/007
Version No.3.0
iii
Context
This document contains assignments to be completed as part of the hands on for the subject COBOL Programming (Course code: LA01). Note: In order to complete the course, assignments in this document must be completed in the sequence mentioned.
Day 1 Assignments
Assignments which are not followed naming conventions will not be evaluated and will be assumed as Incomplete.
Assignment 1: Writing a COBOL Code in the Coding Sheet, Executing and Viewing the output in spool
Objective: To learn how to write a COBOL program in the coding sheet, execute it
using a JCL and viewing the output in spool Problem Description: Write a COBOL program to display the message HELLO WORLD onto the spool. Execute the program through JCL. Estimated time: 10 mins. Step: Play the video file Compile in the DEMOS folder Type the program and execute the same.
Summary of this assignment: How to write a simple COBOL program How to view the data in the spool
Note: Naming Convention to be followed for Day 1 Assignment 1 PDS : TXXXXX.COBOL.DAY1.ASSIGN.PDS Member for COBOL program : TXXXCB01, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC01
ER/CORP/CRS/LA01/007
1 of 49
the spool Problem Description: Few errors have been introduced in the program of Assignment 1. We will execute this program through JCL and interpret the error messages in the spool Estimated time: 10 mins. Step : Play the video file Debug in the DEMOS folder Type the program and execute the same.
Summary of this assignment: In this exercise, you have learnt : How to debug a COBOL program How to interpret the error messages in the spool Note: Naming Convention to be followed for Day 1 Assignment 2 PDS : TXXXXX.COBOL.DAY1.ASSIGN.PDS Member for COBOL program : TXXXCB02, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC02
Standards Problem Description: Refer the reference document provided for coding standards and implement the HELLOW WORLD program with coding standards.
Note: From here on wards, for all the programs, follow the coding
standards.
ER/CORP/CRS/LA01/007
2 of 49
Summary of this assignment: In this exercise, you have learnt: How to write a COBOL program according to Infosys coding standards
Note: Naming Convention to be followed for Day 1 Assignment 3 PDS : TXXXXX.COBOL.DAY1.ASSIGN.PDS Member for COBOL program : TXXXCB03, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC03
Problem Description: Write a COBOL program to evaluate the following expressions using arithmetic verbs ADD, SUBTRACT, MULTIPLY and DIVIDE V = (4/3 ) r3 P = 2 * (l + b) R = (a + b) 2 * (a b)2 Assume the values of a, b, r and l of your own Accept the values of a, b, r and l through JCL Write a JCL to execute the program and display the result in the spool Estimated time: 30 mins
Summary of this assignment: In this exercise, you have learnt : How to use the different forms of arithmetic verbs in a COBOL program
Note: Naming Convention to be followed for Day 1 Assignment 4 PDS : TXXXXX.COBOL.DAY1.ASSIGN.PDS Member for COBOL program : TXXXCB04, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC04
ER/CORP/CRS/LA01/007
3 of 49
Problem Description:
PICTURE clause of the Sending fields and Receiving fields are given in the below table along with the contents being moved to them. Initialize the sending fields using move statements Use Move statements from sending field to receiving field. Sending Field (PIC) 9(5)V99 9(3)V99 9(4)V99 9(3)V99 9(4)V9 9(3)V99 9(3) 9(3) S999 S999 9999 S9999 S9(4)V99 S9(3) S9(6) 9(9) X(10) 999 Contents 0023456 01234 000382 00005 381234 00827 018 027 -459 -493 9143 -9526 -038725 -456 +459342 089743456 PASMITH 153 Receiving Field (PIC) $**,**.99 $***.99 $Z,ZZZ.99 $ZZZ.99 $9,999.99 Z(3) Z(3).ZZ Z(3).99 -999 99-9999 +9(4) +Z,ZZZ.99 9(3)CR 9(6)CR 999BB99BB9999 XBXBX(8) 99900 Output $*2,34.56 $*12.34 $ 3.82 $ .05 $3,812.34 8 18.00 27.00 -459 93b9143(b for blank ) -9526 -bb387.25(b for blank) 456CR 459342bb 089 74 3456 P A SMITH 15300
Write a COBOL program to verify the output in the receiving fields . Refer to the document Edited Picture Clause Rules in the Reference Documents folder under DEMOS for the rules to be used
ER/CORP/CRS/LA01/007
4 of 49
Note: Naming Convention to be followed for Day 1 Assignment 5 PDS : TXXXXX.COBOL.DAY1.ASSIGN.PDS Member for COBOL program : TXXXCB05, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC05
Problem Description: Declare WORKING-STORAGE Variables of the following data types : Numeric Alphabetic Alphanumeric Numeric Non-integer (decimal with PIC symbol V) Edited Numeric Edited Alphanumeric Using MOVE statements validate the Matrix given below for the compatibility of data types. Numeric Edited Edited Numeric non Alphanumeric numeric integer Y N N N Y Y Y N Y Y* N Y Y Y N N Y Y Y N N Y Y Y
Alphabetic Alphanumeric Y Y Y Y Y N Y
Write a JCL to execute the program. Observe the results for compatible moves (Y) and error messages for incompatible moves (N) Estimated time: 45 mins
Summary of this assignment:
ER/CORP/CRS/LA01/007
5 of 49
In this exercise, you have learnt : How to perform compatible moves in COBOL Note: Naming Convention to be followed for Day 1 Assignment 6 PDS : TXXXXX.COBOL.DAY1.ASSIGN.PDS Member for COBOL program : TXXXCB06, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC06
Day 2 Assignments
Assignments which are not followed naming conventions will not be evaluated and will be assumed as Incomplete.
accurate results Background: ON SIZE ERROR clause is used in the arithmetic statements to capture the kind of errors where in the destination is too small to accommodate the result. ON SIZE ERROR would be effective only for the digits before the decimal point. In case of the digits after the decimal point, ROUNDED clause has to be used. Estimated time: 30 mins.
ER/CORP/CRS/LA01/007
6 of 49
Note: Naming Convention to be followed for Day 2 Assignment 1 PDS : TXXXXX.COBOL.DAY2.ASSIGN.PDS Member for COBOL program : TXXXCB01, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC01
Step 1:
TXXXXX.COBOL.DAY2.ASSIGN.PDS
ER/CORP/CRS/LA01/007
7 of 49
Step 2: Save and compile the program using TRNGCOB Step 3: Code the below given JCL in a member TXXXJC01 in PDS
TXXXXX.COBOL.DAY2.ASSIGN.PDS
ER/CORP/CRS/LA01/007
8 of 49
Step 4: Save and submit the JCL Step 5: Observe the output in the spool
Summary of this assignment: How to use ON SIZE ERROR clause to handle precision errors in arithmetic verbs
COBOL Background: PERFORMUNTIL is an iteration construct available in COBOL to repeat a set of statements until the condition is satisfied. It has two kinds of testing done before the body of the loop gets executed:
ER/CORP/CRS/LA01/007
9 of 49
WITH TEST BEFORE : the condition is tested before the body of the loop is executed even once WITH TEST AFTER : the condition is tested after the body of the loop is executed once Estimated time: 30 mins
Note: Naming Convention to be followed for Day 2 Assignment 2 PDS : TXXXXX.COBOL.DAY2.ASSIGN.PDS Member for COBOL program : TXXXCB02, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC02
Step 1:
TXXXXX.COBOL.DAY2.ASSIGN.PDS
ER/CORP/CRS/LA01/007
10 of 49
Step 2: Save and compile the program using TRNGCOB Step 3: Code the below given JCL in a member TXXXJC02 in PDS
TXXXXX.COBOL.DAY2.ASSIGN.PDS
ER/CORP/CRS/LA01/007
11 of 49
Step 4: Save and submit the JCL Step 5: Observe the output in the spool
Summary of this assignment: How to use PERFORM..UNTIL Verb as an iteration construct
Assignment 3: Generation of Pay Slip of an employee using arithmetic verbs, ROUNDED and ON SIZE ERROR clauses
Objective: To learn how to use arithmetic verbs, ROUNDED and ON SIZE ERROR clauses
ER/CORP/CRS/LA01/007
12 of 49
Calculate the DA as 12% of Basic Salary Calculate the Gross as Basic + DA + HRA Use Rounded and ON SIZE ERROR for correct results Use edited Picture Clauses for display wherever necessary. Display the pay slip as below format: Infosys Technologies Limited -----------------------------Paybill for the month of <month> Emp. No : 8900 Emp. Name : Shastry Basic : Rs.xxxx.xx DA : Rs.xxx.xx HRA : Rs.xxx.xx Gross : Rs.xxxxx.xx
Note: Naming Convention to be followed for Day 2 Assignment 3 PDS : TXXXXX.COBOL.DAY2.ASSIGN.PDS Member for COBOL program : TXXXCB03, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC03
Assignment 4: Generating Grade Sheets of students using PERFORM Verbs and IF..THENELSE
Objective: To learn how to use various forms of PERFORM Verbs and IF statements
Problem Description:
Write a COBOL program to create Grade sheets for 2 students in a college. Accept the name of the student and marks in 3 subjects for every student from the user. Calculate the Total, Percentage and Grade for 2 students.
ER/CORP/CRS/LA01/007
13 of 49
Code every functionality (ACCEPT, calculating Total, percentage & grade and display) in separate paragraphs. Use PERFORM . THRU to execute the paragraphs in sequence for each student Use PERFORM..TIMES to repeat the loop for 2 students Use the following criterion to assign grades based on their Percentage marks Percentage Grade >=80 A 70 to 79 B 60 to 69 C 50 to 59 D < 50 E Use IF.THENELSE to check for grades Display the Grade Sheet in the following format : -----------------------------------------------------------------------------------------------------* Mysore University * * Student Name : XXXXXXXXXXXX * -----------------------------------------------------------------------------------------------------Subject Marks ----------------------------------------------------------CHSSC 90 PF 90 RDBMS 90 ----------------------------------------------------------TOTAL 270 ----------------------------------------------------------Percentage 90% -----------------------------------------------------------------------------------------------------GRADE OBTAINED A ------------------------------------------------------------------------------------------------------
Note: Naming Convention to be followed for Day 2 Assignment 4 PDS : TXXXXX.COBOL.DAY2.ASSIGN.PDS Member for COBOL program : TXXXCB04, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC04
ER/CORP/CRS/LA01/007
14 of 49
Assignment 5: Using PERFORM.UNTIL Verb to accept choice from user and display the output
Objective: To learn how to accept the input from the user and perform the display according to the input
Problem Description:
Accept CHOICE from the user (y/n) Accept the NAME, IBU from the user Use PERFORM UNTIL to repeat the loop where the loop has to terminate whenever the user enters N for CHOICE Display the data in spool
Note: Naming Convention to be followed for Day 2 Assignment 5 PDS : TXXXXX.COBOL.DAY2.ASSIGN.PDS Member for COBOL program : TXXXCB05, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC05
Problem Description:
Accept No. of elements N to be generated in a WORKING-STORAGE VARIABLE Use PERFORM..VARYING to generate the series
ER/CORP/CRS/LA01/007
15 of 49
Note: Naming Convention to be followed for Day 2 Assignment 6 PDS : TXXXXX.COBOL.DAY2.ASSIGN.PDS Member for COBOL program : TXXXCB06, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC06
Day 3 Assignments
Assignments which are not followed naming conventions will not be evaluated and will be assumed as Incomplete.
Step 1:
Create a sequential file to store the Employee Records in an organization. The record layout is as follows : EMPNUM PIC 9(5). EMPNAME PIC X(25) DESGINATION PIC A(10) IBU PIC A(10) TELEPHONE PIC 9(7) Note: Naming Convention to be followed for Day 3 Assignment 1 PS : TXXXXX.COBOL.DAY3.ASSIGN.PS
ER/CORP/CRS/LA01/007
16 of 49
Populate the PS file with 5 sample records according to the above layout
Problem Description:
Develop a COBOL program to read the records from the PS file created in step1 (TXXXXX.COBOL.DAY3.ASSIGN.PS) [ Refer to demo T115COB1,T115JCL1] Display the records onto the spool Handle appropriate error conditions
Note: Naming Convention to be followed for Day 3 Assignment 1 PDS : TXXXXX.COBOL.DAY3.ASSIGN.PDS Member for COBOL program : TXXXCB01, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC01
Problem Description:
Accept the records to be inserted through the JCL [ Refer to demo T115COB1,T115JCL1] Develop a COBOL program to read the records from the JCL and write it into the PS file Display successfully written in the spool, if the write is successful Handle appropriate error conditions
ER/CORP/CRS/LA01/007
17 of 49
Note: Naming Convention to be followed for Day 3 Assignment 2 PS to be used : TXXXXX.COBOL.DAY3.ASSIGN.PS (created in step1 of assignment 1) PDS : TXXXXX.COBOL.DAY3.ASSIGN.PDS Member for COBOL program : TXXXCB02, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC02
Problem Description:
Accept 2 records to be appended to the file through the JCL Develop a COBOL program to read the records from the JCL and append it to the PS file Display successfully appended in the spool, if the write is successful Handle appropriate error conditions
Note: Naming Convention to be followed for Day 3 Assignment 3 PS to be used : TXXXXX.COBOL.DAY3.ASSIGN.PS (created in step1 of assignment 1) PDS : TXXXXX.COBOL.DAY3.ASSIGN.PDS Member for COBOL program : TXXXCB03, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC03
Problem Description:
Accept a Telephone Number of an employee from JCL Develop a COBOL program to update the IBU of the employee who is having that telephone number, as IHLD Display successfully updated in the spool, if the update is successful
ER/CORP/CRS/LA01/007
18 of 49
Note: Naming Convention to be followed for Day 3 Assignment 4 PS to be used : TXXXXX.COBOL.DAY3.ASSIGN.PS (created in step1 of assignment 1) PDS : TXXXXX.COBOL.DAY3.ASSIGN.PDS Member for COBOL program : TXXXCB04, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC04
Problem Description: Master PS file contains the data records. Transaction PS file contains the transaction records to be inserted/updated/deleted, to/from a master file. A batch program SEQPROC reads the transaction PS file and according to the flag I (Insert), U (Update) and D (delete) performs the necessary operations in the master PS file. Step 1 : Create a PS master file TXXXXX.COBOL.DAY3.ASSGIN5.PS1
structure and insert 2 records. 01 MASTER-REC. 05 MASTER-EMP-NO 05 FILLER 05 MASTER-EMP-NAME 05 FILLER 05 MASTER-EMP-STATUS 05 FILLER with following
ER/CORP/CRS/LA01/007
19 of 49
05 05 05 05
Step 3 : Write the given COBOL program in the member TXXXCB05 and JCL to execute program in member TXXXJC05 in PDS TXXXXX.COBOL.DAY4.ASSIGN.PDS Refer to SEQPROC and JCLSEQP in the demos. Step 4: Submit the JCL and observe the spool Estimated time: 60 mins
Summary of this assignment: How to manipulate PS file through a batch program
Note: Naming Convention to be followed for Day 3 Assignment 5 PS Master file : TXXXXX.COBOL.DAY3.ASSIGN5.PS1 PS Transaction file : TXXXXX.COBOL.DAY3.ASSIGN5.PS2 PDS : TXXXXX.COBOL.DAY3.ASSIGN.PDS Member for COBOL program : TXXXCB05, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC05
ER/CORP/CRS/LA01/007
20 of 49
Day 4 Assignments
Assignments which are not followed naming conventions will not be evaluated and will be assumed as Incomplete.
Problem Description:
Create a VSAM KSDS file TXXXXX.COBOL.DAY4.ASSIGN1.VSAM with the following record layout : REGNO PIC X(05) (KEY FIELD) NAME PIC A(15) AGE PIC 9(02) Insert the following two records into VSAM file 10000 10002 ANITHA KUMAR SUSHEEL SHARMA 20 21
Step
1:
Code
the
following
program
in
member
TXXXCB01
in
PDS
TXXXXX.COBOL.DAY4.ASSIGN.PDS
ER/CORP/CRS/LA01/007
21 of 49
ER/CORP/CRS/LA01/007
22 of 49
ER/CORP/CRS/LA01/007
23 of 49
Step 2: Save and compile the program using TRNGCOB Step 3: Code the following JCL in a member TXXXJC01 in PDS
TXXXXX.COBOL.DAY4.ASSIGN.PDS
ER/CORP/CRS/LA01/007
24 of 49
Step 4: Save and submit the JCL Step 5: Observe the output in the spool. Open the VSAM file and view the inserted records Estimated time: 60 mins.
Summary of this assignment: How to perform read and write operations in a VSAM KSDS file
Note: Naming Convention to be followed for Day 4 Assignment 1 VSAM : TXXXXX.COBOL.DAY4.ASSIGN1.VSAM PDS : TXXXXX.COBOL.DAY4.ASSIGN.PDS Member for COBOL program : TXXXCB01, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC01
ER/CORP/CRS/LA01/007
25 of 49
Problem Description: Create a VSAM KSDS file TXXXXX.COBOL.DAY4.ASSIGN2.VSAM through File-Aid with the
following record layout : DEPT NUM PIC X(5) [KEY FIELD] DEPTNAME PIC A(15) DEPTLOC PIC A(10) (i) Insertion Write a COBOL program in a member TXXXCB02 to read the records from the JCL and insert it into the VSAM (XXX is last 3 digits of your employee id) Execute the program using JCL TXXXJC02 (ii) Read Write a COBOL program in a member TXXXCB03 to read the records from the VSAM and display it onto the spool Execute the program using JCL- TXXXJC03 (iii) Update Write a COBOL program in a member TXXXCB04 to o Accept the Department Number from JCL o Update the Location of that record to MYSORE Execute the program using JCL TXXXJC04 (iv) Delete Write a COBOL program in a member TXXXCB05 to o Accept the Department Number from JCL o Delete the record from the VSAM Execute the program using JCL TXXXJC05
Note: Naming Convention to be followed for Day 4 Assignment 2 VSAM KSDS file : TXXXXX.COBOL.DAY4.ASSIGN2.VSAM PDS : TXXXXX.COBOL.DAY4.ASSIGN.PDS
ER/CORP/CRS/LA01/007
26 of 49
COPY Verb Problem Description: Copybooks created should have a unique name. The copybooks are stored in the copy library OPERN.CICS1.COPYLIB Step 1: Open the member TXXXCB03 of Assignment 2 in PDS
TXXXXX.COBOL.DAY4.ASSIGN.PDS
Step 2 : Type CC-CC-CREATE for the FD entry and press ENTER. The following screen will appear
ER/CORP/CRS/LA01/007
27 of 49
Step 3 : Type the path of the copybook to be stored with the copybook name. Here the path is OPERN.CICS3.COPYLIB(TXXXCPY1), where XXX is last 3 digits of your mainframe id. Press ENTER. Step 4 : The message Member TXXCPY1 created will appear in the right top corner of the screen.
ER/CORP/CRS/LA01/007
28 of 49
Step 5 : In the member TXXXCB03 , delete the FD entry and replace it with the copybook.
ER/CORP/CRS/LA01/007
29 of 49
Step 6: Save the program and compile using TRNGCOB Step 7: Execute the same through TXXXJC03 Estimated time: 30 mins.
Summary of this assignment: How to create Copybooks and use them in the program
Note: OPERN.CICS1.COPYLIB has to be opened only in VIEW mode to view the contents Copybook name : TXXXCPY1 Member to be used : TXXXCB03, where XXX is last 3 digits of your employee id Member to be used : TXXXJC03
ER/CORP/CRS/LA01/007
30 of 49
Step 3 : Save the program and compile using TRNGCOB Step 4 : Create a member TXXXCB07 in PDS TXXXXX.COBOL.DAY4.ASSIGN.PDS Step 5 : Code the following program
ER/CORP/CRS/LA01/007
31 of 49
Step 6 : Save the program and compile using TRNGCOB Step 7: Create a member TXXXJC06 in PDS TXXXXX.COBOL.DAY4.ASSIGN.PDS Step 8: Code the following JCL
ER/CORP/CRS/LA01/007
32 of 49
Step 9: Save and submit the JCL Step 10: Observe the output in the spool Estimated time: 30 mins.
Summary of this assignment: How to use CALL Verbs to create modular programs
Note: Naming Convention to be followed for Day 4 Assignment 4 PDS : TXXXXX.COBOL.DAY4.ASSIGN.PDS Member for COBOL main program : TXXXCB06 Member for COBOL sub-program : TXXXCB07, where XXX is last 3 digits of your employee id Member for JCL : TXXXJC06
ER/CORP/CRS/LA01/007
33 of 49
include copybooks Problem Description: Convert the Assignment 2 as a menu driven program with modularity Declare a WORKING-STORAGE variable WS-CHOICE to store the users choice. Write a Main Program that will accept the choice. The choice has to be provided through JCL. Use COPY verb to declare the FD entries for the VSAM file In the main program, If Choice = 1 Call the program TXXXCB02. Use CALL Verb. If Choice = 2 Call the program TXXXCB03. Use CALL Verb and pass the RECORD Key through CALL statement from the main program If Choice = 3 Call the program TXXXCB04. Use CALL Verb and pass the Department name through the CALL statement from the main program Implement appropriate error handling for file Estimated time: 45 mins.
Summary of this assignment: How to create modular programs through CALL verb How to use COPY books
Note: Naming Convention to be followed for Day 4 Assignment 5 PDS : TXXXXX.COBOL.DAY4.ASSIGN.PDS VSAM : TXXXXX.COBOL.DAY4.ASSIGN2.VSAM (same file created in Assignment 2) Member for COBOL program : TXXXCB08, where XXX is last 3 digits of employee id Member for JCL : TXXXJC08 Members to be used : TXXXCB03, TXXXCB04, TXXXCB05 (in Assignment 2)
ER/CORP/CRS/LA01/007
34 of 49
the master VSAM KSDS file Problem Description : Master PS file contains the transaction records that are to be updated in the VSAM KSDS master file. Transaction PS file contains the transaction records to be inserted/updated/deleted in a master file. A batch program VSAMPROC reads the transaction PS file and according to the flag I (Insert), U (Update) and D (delete) performs the necessary operations in the master VSAM KSDS file. Step 1 : Create a PS transaction file TXXXXX.COBOL.DAY4.ASSGN6.PS with data Step 2 : Create a VSAM KSDS file TXXXXX.COBOL.DAY4.ASSGN6.VSAM Step 3 : Write the given COBOL program in the member TXXXCB09 and JCL to execute program in member TXXXJC09 in PDS TXXXXX.COBOL.DAY4.ASSIGN.PDS Refer the Demos VSAMPROC, JCLVSAM. Step 4 : Submit the JCL and observe the spool output Estimated time: 50 mins.
Summary of this assignment: How to read the records from a transaction PS file and update the same in the VSAM KSDS master file
Note: Naming Convention to be followed for Day 4 Assignment 6 PS Master file : TXXXXX.COBOL.DAY4.ASSGN6.PS VSAM KSDS file : TXXXXX.COBOL.DAY4.ASSGN6.VSAM PDS : TXXXXX.COBOL.DAY4.ASSIGN.PDS Member for COBOL program : TXXXCB09, where XXX is last 3 digits of employee id Member for JCL : TXXXJC09
ER/CORP/CRS/LA01/007
35 of 49
Background : Alternate Indexes are used in VSAM files for searching operations. Besides primary key field, any other field can be an alternate key (preferably numeric field). Unlike primary key field, alternate key can have duplicate values. Estimated time: 20 mins. Step : Play the media file Alternate Index
Summary of this assignment: How to create an alternate index for a VSAM file and use it in a COBOL program
Day 5 Assignments
Assignments which are not followed naming conventions will not be evaluated and will be assumed as Incomplete.
Step
Code
the
following
program
in
member
TXXXCB01
in
PDS
TXXXXX.COBOL.DAY5.ASSIGN.PDS
ER/CORP/CRS/LA01/007
36 of 49
Step 3 : Save the program and compile using TRNGCOB Step 4 : Create a member TXXXJC01 in PDS TXXXXX.COBOL.DAY5.ASSIGN.PDS Step 5 : Write a JCL to execute the program TXXXJC01 Step 6 Save and submit the JCL Step 7 Observe the output in the spool Estimated time: 30 mins.
Summary of this assignment: How to create one dimensional array and populate them with data
ER/CORP/CRS/LA01/007
37 of 49
Note: Naming Convention to be followed for Day 5 - Assignment 1 PDS : TXXXXX.COBOL.DAY5.ASSIGN.PDS Member for COBOL program : TXXXCB01, where XXX is last 3 digits of employee id Member for JCL : TXXXJC01
Verbs
Background: STRING Verb is used in COBOL to concatenate separate strings into one
string. UNSTRING verb is used to split a string into various elementary strings Step 1 : Code the following program in a member TXXXCB02
ER/CORP/CRS/LA01/007
38 of 49
Step 2 : Save the program and compile using TRNGCOB Step 3 : Write a JCL to execute the program in a member TXXXJC02 Step 4 : Save and submit the JCL Step 5 : Observe the output in the spool Estimated time: 20 mins.
Summary of this assignment: How to concatenate strings using STRING Verb and split the strings using UNSTRING Verb
Note: Naming Convention to be followed for Day 5 - Assignment 2 PDS : TXXXXX.COBOL.DAY5.ASSIGN.PDS Member for COBOL program : TXXXCB02, where XXX is last 3 digits of employee id Member for JCL : TXXXJC02
ER/CORP/CRS/LA01/007
39 of 49
Counting the number of characters in a string Replacing a pattern of characters into another pattern between characters The various modifying phrases used with INSPECT are : LEADING inspects the position of a character FIRST inspects the first occurrence of a character Step 1: Code the following program in a member TXXXCB03 in PDS
TXXXXX.COBOL.DAY5.ASSIGN.PDS
Step 2 : Save the program and compile using TRNGCOB Step 3 : Write a JCL to execute the program in a member TXXXJC03
ER/CORP/CRS/LA01/007
40 of 49
Step 4 : Save and submit the JCL Step 5 : Observe the output in the spool Estimated time: 30 mins.
Summary of this assignment: How to use INSPECT Verb for counting the number of characters in a string and replacing the characters
Note: Naming Convention to be followed for Day 5 - Assignment 3 PDS : TXXXXX.COBOL.DAY5.ASSIGN.PDS Member for COBOL program : TXXXCB03, where XXX is last 3 digits of employee id Member for JCL : TXXXJC03
search can be performed on an array : Linear Search Binary Search COBOL provides different verbs for both the searches. SEARCH performs a linear search on a table to find an element. SEARCH ALL performs a binary search on a table to find an element Step 1 : Code the following program in a member TXXXCB04 in PDS
TXXXXX.COBOL.DAY5.ASSIGN.PDS
ER/CORP/CRS/LA01/007
41 of 49
ER/CORP/CRS/LA01/007
42 of 49
Step 2 : Save the program and compile using TRNGCOB Step 3 : Code the following JCL in a member TXXXJC04
ER/CORP/CRS/LA01/007
43 of 49
Step 4 : Save and submit the JCL Step 5 : Observe the output in the spool Estimated time: 30 mins.
Summary of this assignment: How to use SEARCH ALL Verb to perform a binary search on a table
Note: Naming Convention to be followed for Day 5 - Assignment 4 PDS : TXXXXX.COBOL.DAY5.ASSIGN.PDS Member for COBOL program : TXXXCB04, where XXX is last 3 digits of employee id Member for JCL : TXXXJC04
ER/CORP/CRS/LA01/007
44 of 49
programming clauses. REDEFINES can be used to provide a new name for an existing memory declaration. RENAMES can be used to create a new group out of the existing group items Step 1 : Code the following program in a member TXXXCB05 of PDS
TXXXXX.COBOL.DAY5.ASSIGN.PDS
ER/CORP/CRS/LA01/007
45 of 49
Step 2 : Save the program and compile using TRNGCOB Step 3 : Code the following JCL in a member TXXXJC05
ER/CORP/CRS/LA01/007
46 of 49
Step 4 : Save and submit the JCL Step 5 : Observe the output in the spool Estimated time: 30 mins.
Summary of this assignment: How to use RENAMES and REDEFINES Clauses in a COBOL program
Note: Naming Convention to be followed for Day 5 - Assignment 5 PDS : TXXXXX.COBOL.DAY5.ASSIGN.PDS Member for COBOL program : TXXXCB05, where XXX is last 3 digits of employee id Member for JCL : TXXXJC05
ER/CORP/CRS/LA01/007
47 of 49
Problem Description: Develop a modular COBOL program to perform the following string handling functions using INSPECT, STRING and UNSTRING Every functionality has to be defined in separate paragraphs Each paragraph has to be called through PERFORM statement from the main paragraph Declare a string with value EDUCATION AND RESEARCH Use INSPECT Verb to :
o o o Count the number of occurrences of A and E in the string Replace the character 'A' by 'Z' before the first occurrence of O. Replace all the characters 'E' by 'M' occurring before 'D'.
Use STRING Verb with POINTER and OVERFLOW option to display the following strings in spool :
Mainframes Supports Virtual Storage *********Mainframes Supports virtual storage (* denotes blanks)
ER/CORP/CRS/LA01/007
48 of 49
Note: Naming Convention to be followed for Day 5 Assignment 6 PDS : TXXXXX.COBOL.DAY5.ASSIGN.PDS Member for COBOL program : TXXXCB06, where XXX is last 3 digits of employee id Member for JCL : TXXXJC06
ER/CORP/CRS/LA01/007
49 of 49