LabGuide_COBOL_LA01_LC.pdf

  • Upload
    lakshmi

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    1/54

    COMPANY CONFIDENTIAL

    Lab Guide for COBOL Programming

    Author(s) Karthigai Priya G/Fayaz Basha S.K.

    Authorized by Dr.M.P.Ravindra

    Creation/Revision Date 03-2007

    Version 3.0

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    2/54

    COPYRIGHT NOTICE

    All ideas and information contained in this document are the intellectual property ofEducation and Research Department, Infosys Technologies Limited. This document is

    not for general distribution and is meant for use only for the person they arespecifically issued to. This document shall not be loaned to anyone, within or outsideInfosys, including its customers. Copying or unauthorized distribution of thisdocument, in any form or means including electronic, mechanical, photocopying orotherwise is illegal.

    Education and Research DepartmentInfosys Technologies Limited

    Electronic CityHosur Road

    Bangalore - 561 229, India.

    Tel: 91 80 852 0261-270Fax: 91 80 852 0362

    www.infy.commailto:E&[email protected]

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    3/54

    Infosys Technologies Limited Document Revision History

    ER/CORP/CRS/LA01/007 Version No :3.0 i

    Document Revision History

    Version Date Author(s) Reviewer(s) Comments0.0 Aug-05 Narasimha

    Murthy/Priya

    Murali

    Konareddy

    Initial Draft

    1.0 Sep-06 Murali/ NarasimhaMurthy/Priya

    MuraliKonareddy

    Incorporated thereview comments

    2.0 03-2007 Karthigai PriyaG/Fayaz Basha S.K.

    MuraliKonareddy

    FP Restructure 2006-2007

    3.0 Sep-2007 Fayaz Basha SK MuraliKonareddy /Shashank

    FP Restructure 2006-2007

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    4/54

    Infosys Technologies Limited Table of Contents

    ER/CORP/CRS/LA01/007 Version No.3.0 ii

    Contents

    COPYRIGHT NOTICE ....................................................................................................... ICOPYRIGHT NOTICE ...................................................................................................... IIDOCUMENT REVISION HISTORY ......................................................................................... ICONTENTS .................................................................................................................. IICONTEXT ................................................................................................................... 1DAY 1 ASSIGNMENTS ..................................................................................................... 1

    ASSIGNMENT 1:WRITING A COBOLCODE IN THE CODING SHEET,EXECUTING AND VIEWING THE OUTPUT IN SPOOL ....... 1ASSIGNMENT 2:DEBUGGING A COBOL PROGRAM .......................................................................... 2ASSIGNMENT 3:UNDERSTANDING COBOLCODING STANDARDS............................................................. 2ASSIGNMENT 4:UNDERSTANDING ARITHMETIC STATEMENTS IN COBOL .................................................... 3ASSIGNMENT 5:UNDERSTANDING EDITED PICTURE CLAUSES AND MOVEVERB ............................................. 4ASSIGNMENT 6:UNDERSTANDING THE LEGALMOVES IN COBOL ......................................................... 5ASSIGNMENT 7:EXERCISES FOR SELF REVIEW............................................................................... 6

    DAY 2 ASSIGNMENTS ..................................................................................................... 6ASSIGNMENT 1:DEMONSTRATION OF ONSIZEERRORCLAUSE ............................................................ 6ASSIGNMENT 2:UNDERSTANDING PERFORM..UNTILVERB ............................................................. 9ASSIGNMENT 3:GENERATION OF PAY SLIP OF AN EMPLOYEE USING ARITHMETIC VERBS,ROUNDED AND ONSIZEERROR

    CLAUSES .................................................................................................................. 12ASSIGNMENT 4:GENERATING GRADE SHEETS OF STUDENTS USING PERFORMVERBS AND IF..THENELSE ............ 13ASSIGNMENT 5:USING PERFORM.UNTILVERB TO ACCEPT CHOICE FROM USER AND DISPLAY THE OUTPUT ............ 15ASSIGNMENT 6:USING PERFORM.VARYING TO GENERATE N ELEMENTS OF FIBONACCI SERIES ..................... 15ASSIGNMENT 7:EXERCISES FOR SELF REVIEW............................................................................. 16

    DAY 3 ASSIGNMENTS ................................................................................................... 16ASSIGNMENT 1:CREATION OF PS FILE AND UNDERSTANDING THE READ OPERATION OF A PS FILE ......................... 16ASSIGNMENT 2:UNDERSTANDING WRITE OPERATION OF A PS FILE........................................................ 17ASSIGNMENT 3:APPENDING RECORDS TO A PS FILE....................................................................... 18ASSIGNMENT 4:UPDATING RECORDS IN A PS FILE......................................................................... 18ASSIGNMENT 5:UNDERSTANDING SEQUENTIAL FILE MANIPULATIONS ...................................................... 19ASSIGNMENT 6:EXERCISES FOR SELF REVIEW............................................................................. 20

    DAY 4 ASSIGNMENTS ................................................................................................... 21ASSIGNMENT 1:UNDERSTANDING READ AND WRITE OPERATIONS IN A VSAMKSDS FILE ................................ 21ASSIGNMENT 2:UNDERSTANDING THE VSAMKSDS FILE MANIPULATIONS................................................ 26ASSIGNMENT 3:UNDERSTANDING COPYVERB ........................................................................... 27ASSIGNMENT 4:UNDERSTANDING CALLVERB ........................................................................... 31ASSIGNMENT 5:CREATION OF MODULAR COBOL PROGRAMS ............................................................. 34ASSIGNMENT 6:UNDERSTANDING VSAMKSDSFILE AND PSFILE MANIPULATIONS ........................................ 35ASSIGNMENT 7:CREATION OF ALTERNATE INDEX FOR A VSAMKSDS FILE ................................................ 35ASSIGNMENT 8:EXERCISES FOR SELF REVIEW............................................................................. 36

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    5/54

    Infosys Technologies Limited Table of Contents

    ER/CORP/CRS/LA01/007 Version No.3.0 iii

    DAY 5 ASSIGNMENTS ................................................................................................... 36ASSIGNMENT 1:DEMONSTRATION OF ONE DIMENSIONAL ARRAY........................................................... 36ASSIGNMENT 2:DEMONSTRATION OF STRING AND UNSTRINGVERB.................................................... 38ASSIGNMENT 3:DEMONSTRATION OF INSPECTVERB .................................................................... 40ASSIGNMENT 4:DEMONSTRATION OF SEARCHALLVERB ................................................................ 41ASSIGNMENT 5:DEMONSTRATION OF REDEFINES AND RENAMESCLAUSES ............................................. 45ASSIGNMENT 6:UNDERSTANDING STRING HANDLING VERBS .............................................................. 48ASSIGNMENT 7:EXERCISES FOR SELF REVIEW............................................................................. 49

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    6/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 1 of 49

    ContextThis document contains assignments to be completed as part of the hands on for the subjectCOBOL Programming (Course code: LA01).

    Note: In order to complete the course, assignments in this document must be completed inthe sequence mentioned.

    Day 1 Assignments

    Assignments which are not followed naming conventionswill not be evaluated and will be assumed as Incomplete.

    Assignment 1: Writing a COBOL Code in the Coding Sheet, Executingand Viewing the output in spool

    Objective: To learn how to write a COBOL program in the coding sheet, execute itusing a JCL and viewing the output in spool

    Problem Description: Write a COBOL program to display the message HELLO WORLDonto the spool. Execute the program through JCL.

    Estimated time: 10 mins.

    Step: Play the video file Compile in the DEMOS folderType 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.PDSMember for COBOL program : TXXXCB01, where XXX is last 3 digits of your

    employee idMember for JCL :TXXXJC01

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    7/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 2 of 49

    Assignment 2: Debugging a COBOL program

    Objective:To learn how to debug a COBOL program and interpret the JES messages inthe spool

    Problem Description: Few errors have been introduced in the program of Assignment1. We will execute this program through JCL and interpret the error messages in thespool

    Estimated time: 10 mins.

    Step : Play the video file Debug in the DEMOS folderType 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.PDSMember for COBOL program :TXXXCB02, where XXX is last 3 digits of your

    employee idMember for JCL :TXXXJC02

    Assignment 3: Understanding COBOL Coding Standards

    Objective: To learn how to write a COBOL program according to Infosys CodingStandards

    Problem Description:Refer the reference document provided for coding standards andimplement the HELLOW WORLD program with coding standards.

    Note:From here on wards, for all the programs, follow the codingstandards.

    Estimated time: 30 mins.

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    8/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 3 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.PDSMember for COBOL program :TXXXCB03, where XXX is last 3 digits of your

    employee idMember for JCL :TXXXJC03

    Assignment 4: Understanding Arithmetic Statements in COBOL

    Objective:To understand the usage of arithmetic statements in COBOL

    Problem Description:Write a COBOL program to evaluate the following expressions using arithmeticverbs 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 youremployee id

    Member for JCL :TXXXJC04

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    9/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 4 of 49

    Assignment 5: Understanding Edited Picture Clauses and MOVE Verb

    Objective:To understand the use of Edited Picture Clauses in COBOL

    Problem Description:

    PICTURE clause of the Sending fields and Receiving fields are given in the below tablealong with the contents being moved to them.Initialize the sending fields using move statementsUse Move statements from sending field to receiving field.

    Sending Field (PIC) Contents Receiving Field (PIC) Output

    9(5)V99 0023456 $**,**.99 $*2,34.56

    9(3)V99 01234 $***.99 $*12.34

    9(4)V99 000382 $Z,ZZZ.99 $ 3.82

    9(3)V99 00005 $ZZZ.99 $ .05

    9(4)V9 381234 $9,999.99 $3,812.349(3)V99 00827 Z(3) 8

    9(3) 018 Z(3).ZZ 18.00

    9(3) 027 Z(3).99 27.00

    S999 -459 -999 -459

    S999 -493 99- 93-

    9999 9143 -9999 b9143(b for blank )

    S9999 -9526 +9(4) -9526

    S9(4)V99 -038725 +Z,ZZZ.99 -bb387.25(b for blank)

    S9(3) -456 9(3)CR 456CR

    S9(6) +459342 9(6)CR 459342bb9(9) 089743456 999BB99BB9999 089 74 3456

    X(10) PASMITH XBXBX(8) P A SMITH

    999 153 99900 15300

    Write a COBOL program to verify the output in the receiving fields .Refer to the document Edited Picture Clause Rules in the Reference Documentsfolder under DEMOS for the rules to be usedWrite a JCL to execute the program

    Estimated time: 60 mins

    Summary of this assignment:

    In this exercise, you have learnt :

    How to use Edited Picture Clauses How to use MOVE Verb

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    10/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 5 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 youremployee id

    Member for JCL :TXXXJC05

    Assignment 6: Understanding the LEGAL MOVES in COBOL

    Objective:To understand the Legal MOVE Matrix for various data types

    Problem Description:Declare WORKING-STORAGE Variables of the following data types :

    Numeric

    AlphabeticAlphanumericNumeric Non-integer (decimal with PIC symbol V)Edited NumericEdited Alphanumeric

    Using MOVE statements validate the Matrix given below for the compatibility of datatypes.

    Data Types Alphabetic AlphanumericEditedAlphanumeric

    NumericNumericnoninteger

    Editednumeric

    Alphabetic Y Y Y N N N

    Alphanumeric Y Y Y Y* N N

    EditedAlphanumeric

    Y Y Y N N N

    Numeric N Y Y Y Y Y

    Numeric noninteger

    N N N Y Y Y

    Editednumeric

    N Y Y Y Y Y

    Write a JCL to execute the program.Observe the results for compatible moves (Y) and error messages forincompatible moves (N)

    Estimated time: 45 mins

    Summary of this assignment:

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    11/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 6 of 49

    In this exercise, you have learnt :

    How to perform compatible moves in COBOLNote:Naming Convention to be followed for Day 1 Assignment 6

    PDS : TXXXXX.COBOL.DAY1.ASSIGN.PDSMember for COBOL program :TXXXCB06, where XXX is last 3 digits of youremployee id

    Member for JCL : TXXXJC06

    Assignment 7: Exercises for Self Review

    1. What are the different data types available in COBOL?2. Give the syntax of the DIVISION Verb to store the REMAINDER and the Quotient3. What is the use of GIVING clause in Arithmetic statements?

    4. What is the use of JUSTIFIED clause in a alphabetic MOVE statement?

    Day 2 Assignments

    Assignments which are not followed naming conventions

    will not be evaluated and will be assumed as Incomplete.

    Assignment 1: Demonstration of ON SIZE ERROR Clause

    Objective:To learn how to use the ON SIZE ERROR Clause with arithmetic verbs foraccurate results

    Background: ON SIZE ERRORclause is used in the arithmetic statements to capturethe 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 caseof the digits after the decimal point, ROUNDED clause has to be used.

    Estimated time: 30 mins.

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    12/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 7 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 idMember for JCL :TXXXJC01

    Step 1: Code the below given program in a member TXXXCB01 in PDSTXXXXX.COBOL.DAY2.ASSIGN.PDS

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    13/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 8 of 49

    Step 2: Save and compile the program using TRNGCOB

    Step 3: Code the below given JCL in a member TXXXJC01 in PDSTXXXXX.COBOL.DAY2.ASSIGN.PDS

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    14/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 9 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

    Assignment 2: Understanding PERFORM..UNTIL Verb

    Objective:To learn how to use the PERFORM..UNTIL Verb as an iteration construct inCOBOL

    Background: PERFORMUNTIL is an iteration construct available in COBOL to repeata set of statements until the condition is satisfied. It has two kinds of testing donebefore the body of the loop gets executed:

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    15/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 10 of 49

    WITH TEST BEFORE : the condition is tested before the body of the loop isexecuted even once

    WITH TEST AFTER : the condition is tested after the body of the loop isexecuted once

    Estimated time: 30 mins

    Note:Naming Convention to be followed for Day 2 Assignment 2

    PDS : TXXXXX.COBOL.DAY2.ASSIGN.PDSMember for COBOL program : TXXXCB02, where XXX is last 3 digits of youremployee id

    Member for JCL :TXXXJC02

    Step 1: Code the below given program in a member TXXXCB02 in PDSTXXXXX.COBOL.DAY2.ASSIGN.PDS

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    16/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 11 of 49

    Step 2: Save and compile the program using TRNGCOB

    Step 3: Code the below given JCL in a member TXXXJC02 in PDSTXXXXX.COBOL.DAY2.ASSIGN.PDS

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    17/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 12 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 arithmeticverbs, ROUNDED and ON SIZE ERROR clauses

    Objective:To learn how to use arithmetic verbs, ROUNDED and ON SIZE ERROR clausesto provide results with accurate precision

    Problem Description:

    Accept the Basic Salary and HRA from user

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    18/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 13 of 49

    Calculate the DA as 12% of Basic Salary

    Calculate the Gross as Basic + DA + HRAUse 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

    Emp. No : 8900Emp. Name : Shastry

    Basic : Rs.xxxx.xxDA : Rs.xxx.xx

    HRA : Rs.xxx.xx

    Gross : Rs.xxxxx.xx

    Estimated time: 40 mins

    Summary of this assignment:

    How to use arithmetic verbs, ROUNDED and ON SIZE ERROR clauses in COBOL program

    Note:Naming Convention to be followed for Day 2 Assignment 3

    PDS : TXXXXX.COBOL.DAY2.ASSIGN.PDSMember for COBOL program : TXXXCB03, where XXX is last 3 digits of youremployee id

    Member for JCL :TXXXJC03

    Assignment 4: Generating Grade Sheets of students using PERFORMVerbs 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.

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    19/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 14 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 studentsUse 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

    ------------------------------------------------------------------------------------------------------

    Estimated time: 40 mins

    Summary of this assignment:

    How to use PERFORM Verbs and IF statements

    Note:Naming Convention to be followed for Day 2 Assignment 4

    PDS : TXXXXX.COBOL.DAY2.ASSIGN.PDSMember for COBOL program : TXXXCB04, where XXX is last 3 digits of your

    employee idMember for JCL :TXXXJC04

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    20/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 15 of 49

    Assignment 5: Using PERFORM.UNTIL Verb to accept choice from userand display the output

    Objective:To learn how to accept the input from the user and perform the displayaccording 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 terminatewhenever the user enters N for CHOICE

    Display the data in spool

    Estimated time: 20 mins

    Summary of this assignment:

    How to use accept the inputs from the user and display it on the spool usingPERFORM.UNTIL verb

    Note:Naming Convention to be followed for Day 2 Assignment 5

    PDS : TXXXXX.COBOL.DAY2.ASSIGN.PDSMember for COBOL program : TXXXCB05, where XXX is last 3 digits of youremployee id

    Member for JCL :TXXXJC05

    Assignment 6: Using PERFORM.VARYING to generate N elements ofFibonacci Series

    Objective:To learn how to use PERFORMVARYING Verb to generate Fibonacci series

    Problem Description:Accept No. of elements N to be generated in a WORKING-STORAGE VARIABLE

    Use PERFORM..VARYING to generate the series

    Estimated time: 20 mins

    Summary of this assignment:

    How to use PERFORMVARYING Verb

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    21/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 16 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 idMember for JCL :TXXXJC06

    Assignment 7: Exercises for Self Review

    1. What is the difference between PERFORMWITH TEST BEFORE and WITH TEST AFTER?2. When coded in a COBOL program what does STOP RUN do?

    3. What are condition names and condition variables?4. List down the level numbers used for condition variables and condition names5. Give the syntax of PERFORMVARYING statement

    Day 3 Assignments

    Assignments which are not followed naming conventionswill not be evaluated and will be assumed as Incomplete.

    Assignment 1: Creation of PS file and understanding the ReadOperation of a PS file

    Objective:To learn how to create a PS data file for read, write and update operations

    Step 1:Create a sequential file to store the Employee Records in an organization. The recordlayout 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

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    22/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 17 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

    Estimated time: 55 mins.

    Summary of this assignment:

    How to read the records from a PS file and display them on the spool

    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 idMember for JCL :TXXXJC01

    Assignment 2: Understanding Write operation of a PS file

    Objective:To learn how to insert records to a PS file

    Problem Description:Accept the records to be inserted through the JCL [ Refer to demoT115COB1,T115JCL1]

    Develop a COBOL program to read the records from the JCL and write it into the PSfileDisplay successfully written in the spool, if the write is successfulHandle appropriate error conditions

    Estimated time: 40 mins.

    Summary of this assignment:

    How to insert the records to a PS file

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    23/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 18 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.PDSMember for COBOL program : TXXXCB02, where XXX is last 3 digits of youremployee id

    Member for JCL :TXXXJC02

    Assignment 3: Appending records to a PS file

    Objective:To learn how to append records to the PS file

    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 PSfileDisplay successfully appended in the spool, if the write is successful

    Handle appropriate error conditions

    Estimated time: 10 mins

    Summary of this assignment:

    How to append the records to a PS file

    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 youremployee id

    Member for JCL :TXXXJC03

    Assignment 4: Updating records in a PS file

    Objective:To learn how to update a record in a PS file

    Problem Description:Accept a Telephone Number of an employee from JCLDevelop a COBOL program to update the IBU of the employee who is having that

    telephone number, as IHLDDisplay successfully updated in the spool, if the update is successful

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    24/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 19 of 49

    Handle appropriate error conditions

    Estimated time: 45 mins.

    Summary of this assignment:

    How to update a record in a PS file

    Note:Naming Convention to be followed for Day 3 Assignment 4

    PS to be used : TXXXXX.COBOL.DAY3.ASSIGN.PS (created in step1 ofassignment 1)PDS : TXXXXX.COBOL.DAY3.ASSIGN.PDS

    Member for COBOL program : TXXXCB04, where XXX is last 3 digits of youremployee id

    Member for JCL :TXXXJC04

    Assignment 5: Understanding Sequential File manipulations

    Objective:To learn how to manipulate the transaction records in a PS file

    Problem Description: Master PS file contains the data records. Transaction PS filecontains the transaction records to be inserted/updated/deleted, to/from a masterfile. A batch program SEQPROC reads the transaction PS file and according to the flagI (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 with followingstructure and insert 2 records.

    01 MASTER-REC.05 MASTER-EMP-NO PIC 9(5).05 FILLER PIC X.

    05 MASTER-EMP-NAME PIC X(25).05 FILLER PIC X.

    05 MASTER-EMP-STATUS PIC X(1).

    05 FILLER PIC X(47).

    Step 2 : Create a PS transaction file TXXXXX.COBOL.DAY3.ASSIGN5.PS2 with followingstructure and insert 6 sample records. (2 for each transaction)01 TRANS-REC.

    05 TRANS-FLAG PIC X(1).05 FILLER PIC X.

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    25/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 20 of 49

    05 TRANS-EMP-NO PIC 9(5).

    05 FILLER PIC X.05 TRANS-EMP-NAME PIC X(25).

    05 FILLER PIC X(47).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.PS1PS Transaction file : TXXXXX.COBOL.DAY3.ASSIGN5.PS2

    PDS : TXXXXX.COBOL.DAY3.ASSIGN.PDSMember for COBOL program : TXXXCB05, where XXX is last 3 digits of youremployee id

    Member for JCL :TXXXJC05

    Assignment 6: Exercises for Self Review

    1. In which mode do we open a PS file to append the records?

    2. Give the syntax of REWRITE and DELETE statements in a PS file3. What is the use of RECORD BUFFERS while using files in COBOL?4. Given below the details of a PS file , code the ENVIRONMENT DIVISION entries (SELECTSTATEMENT along with FILE STATUS)

    Physical File name : DOCFILELogical File name : USRFILE

    File Status variable : WS-FS

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    26/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 21 of 49

    Day 4 Assignments

    Assignments which are not followed naming conventions

    will not be evaluated and will be assumed as Incomplete.

    Assignment 1: Understanding READ and WRITE operations in a VSAMKSDS file

    Objective:To learn how to perform READ and WRITE operation in a VSAM KSDS file

    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 ANITHA KUMAR 20

    10002 SUSHEEL SHARMA 21

    Step 1: Code the following program in a member TXXXCB01 in PDSTXXXXX.COBOL.DAY4.ASSIGN.PDS

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    27/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 22 of 49

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    28/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 23 of 49

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    29/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 24 of 49

    Step 2: Save and compile the program using TRNGCOB

    Step 3: Code the following JCL in a member TXXXJC01 in PDSTXXXXX.COBOL.DAY4.ASSIGN.PDS

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    30/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 25 of 49

    Step 4: Save and submit the JCL

    Step 5: Observe the output in the spool. Open the VSAM file and view the insertedrecords

    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.PDSMember for COBOL program : TXXXCB01, where XXX is last 3 digits of youremployee id

    Member for JCL :TXXXJC01

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    31/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 26 of 49

    Assignment 2: Understanding the VSAM KSDS file Manipulations

    Objective:To learn how to perform updation and deletion in a VSAM KSDS file

    Problem Description:

    Create a VSAM KSDS file TXXXXX.COBOL.DAY4.ASSIGN2.VSAM through File-Aid with thefollowing 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 fromthe 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 spoolExecute the program using JCL- TXXXJC03

    (iii) Update

    Write a COBOL program in a member TXXXCB04 to

    o Accept the Department Number from JCLo Update the Location of that record to MYSORE

    Execute the program using JCL TXXXJC04(iv) Delete

    Write a COBOL program in a member TXXXCB05 too Accept the Department Number from JCLo Delete the record from the VSAM

    Execute the program using JCL TXXXJC05

    Estimated time: 60 mins.

    Summary of this assignment:

    How to read the records from a PS file and display them on the spool

    Note:Naming Convention to be followed for Day 4 Assignment 2

    VSAM KSDS file : TXXXXX.COBOL.DAY4.ASSIGN2.VSAMPDS : TXXXXX.COBOL.DAY4.ASSIGN.PDS

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    32/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 27 of 49

    Assignment 3: Understanding COPY Verb

    Objective:To learn how to create Copybooks and use them in the program throughCOPY Verb

    Problem Description: Copybooks created should have a unique name. The copybooksare stored in the copy library OPERN.CICS1.COPYLIB

    Step 1: Open the member TXXXCB03 of Assignment 2 in PDSTXXXXX.COBOL.DAY4.ASSIGN.PDS

    Step 2 : Type CC-CC-CREATE for the FD entry and press ENTER. The following screenwill appear

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    33/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 28 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 yourmainframe id. Press ENTER.

    Step 4 : The message Member TXXCPY1 created will appear in the right top cornerof the screen.

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    34/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 29 of 49

    Step 5 : In the member TXXXCB03 , delete the FD entry and replace it with the

    copybook.

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    35/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 30 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 idMember to be used : TXXXJC03

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    36/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 31 of 49

    Assignment 4 : Understanding CALL Verb

    Objective:To learn how to use CALL Verb to create modular programs

    Step 1 : Code the following program in a member TXXXCB06

    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

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    37/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 32 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

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    38/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 33 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.PDSMember for COBOL main program : TXXXCB06

    Member for COBOL sub-program : TXXXCB07, where XXX is last 3 digits ofyour employee id

    Member for JCL :TXXXJC06

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    39/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 34 of 49

    Assignment 5: Creation of Modular COBOL programs

    Objective: To learn how to create modular programs using CALL verb and how toinclude copybooks

    Problem Description:

    Convert the Assignment 2 as a menu driven program with modularity

    Declare a WORKING-STORAGE variable WS-CHOICE to store the userschoice.Write a Main Program that will accept the choice. The choice has to beprovided through JCL.Use COPY verb to declare the FD entries for the VSAM fileIn 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 theRECORD Key through CALL statement from the main programIf Choice = 3

    Call the program TXXXCB04. Use CALL Verb and pass theDepartment name through the CALL statement from the mainprogram

    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.PDSVSAM : TXXXXX.COBOL.DAY4.ASSIGN2.VSAM (same file created in Assignment 2)

    Member for COBOL program : TXXXCB08, where XXX is last 3 digits of

    employee idMember for JCL :TXXXJC08Members to be used : TXXXCB03, TXXXCB04, TXXXCB05 (in Assignment 2)

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    40/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 35 of 49

    Assignment 6: Understanding VSAM KSDS File and PS File manipulations

    Objective:To learn how to manipulate the transaction records in a PS file and updatethe master VSAM KSDS file

    Problem Description : Master PS file contains the transaction records that are to beupdated in the VSAM KSDS master file. Transaction PS file contains the transactionrecords to be inserted/updated/deleted in a master file. A batch program VSAMPROCreads 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 VSAMKSDS master file

    Note:Naming Convention to be followed for Day 4 Assignment 6

    PS Master file : TXXXXX.COBOL.DAY4.ASSGN6.PSVSAM KSDS file : TXXXXX.COBOL.DAY4.ASSGN6.VSAM

    PDS : TXXXXX.COBOL.DAY4.ASSIGN.PDSMember for COBOL program : TXXXCB09, where XXX is last 3 digits of

    employee idMember for JCL :TXXXJC09

    Assignment 7: Creation of Alternate Index for a VSAM KSDS file

    Objective:To learn how to create an alternate index for a VSAM KSDS file

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    41/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 36 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 numericfield). 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

    Assignment 8: Exercises for Self Review

    1. Give the syntax of SELECT statement for a VSAM with ALTERNATE INDEX2. What is the use of FD entries in ENVIRONMENT division?3. In the below given SELECT statement identify the physical and logical filenames ;

    ENVIRONMENT DIVISION.INPUT-OUTPUT SECTION.

    FILE-CONTROL.SELECT EMPFILE ASSIGN TO QSFILEORGANIZATION IS INDEXEDACCESS IS RANDOM.

    4. Which PDS is used to store the copybooks created by TSO users?5. What is the use of LINKAGE SECTION while using CALL statement?

    Day 5 Assignments

    Assignments which are not followed naming conventionswill not be evaluated and will be assumed as Incomplete.

    Assignment 1: Demonstration of One Dimensional Array

    Objective:To learn how to create an one dimensional array and populate it with data

    Step 1 : Code the following program in a member TXXXCB01 in PDSTXXXXX.COBOL.DAY5.ASSIGN.PDS

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    42/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 37 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

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    43/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 38 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 idMember for JCL :TXXXJC01

    Assignment 2: Demonstration of STRING and UNSTRING Verb

    Objective:To learn how to perform string manipulations using STRING and UNSTRINGVerbs

    Background:STRING Verb is used in COBOL to concatenate separate strings into onestring. UNSTRING verb is used to split a string into various elementary strings

    Step 1 : Code the following program in a member TXXXCB02

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    44/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 39 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 UNSTRINGVerb

    Note:Naming Convention to be followed for Day 5 - Assignment 2

    PDS : TXXXXX.COBOL.DAY5.ASSIGN.PDSMember for COBOL program : TXXXCB02, where XXX is last 3 digits ofemployee id

    Member for JCL :TXXXJC02

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    45/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 40 of 49

    Assignment 3: Demonstration of INSPECT Verb

    Objective:To learn how to perform string manipulations using INSPECT Verb

    Background:INSPECT Verb can do various functions like :

    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 PDSTXXXXX.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

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    46/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 41 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 andreplacing the characters

    Note:Naming Convention to be followed for Day 5 - Assignment 3

    PDS : TXXXXX.COBOL.DAY5.ASSIGN.PDSMember for COBOL program : TXXXCB03, where XXX is last 3 digits of

    employee idMember for JCL :TXXXJC03

    Assignment 4: Demonstration of SEARCH ALL Verb

    Objective:To learn how to search for an element in a table

    Background: SEARCH Verb is used to search an element in an array. Two types ofsearch can be performed on an array : Linear Search Binary Search

    COBOL provides different verbs for both the searches. SEARCH performs a linearsearch on a table to find an element. SEARCH ALL performs a binary search on a tableto find an element

    Step 1 : Code the following program in a member TXXXCB04 in PDSTXXXXX.COBOL.DAY5.ASSIGN.PDS

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    47/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 42 of 49

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    48/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 43 of 49

    Step 2 : Save the program and compile using TRNGCOB

    Step 3 : Code the following JCL in a member TXXXJC04

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    49/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 44 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 ofemployee id

    Member for JCL :TXXXJC04

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    50/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 45 of 49

    Assignment 5: Demonstration of REDEFINES and RENAMES Clauses

    Objective:To learn how to use REDEFINES and RENAMES clauses

    Background: COBOL provides a way for reusability of code through certain

    programming clauses. REDEFINES can be used to provide a new name for an existingmemory declaration. RENAMES can be used to create a new group out of the existinggroup items

    Step 1 : Code the following program in a member TXXXCB05 of PDSTXXXXX.COBOL.DAY5.ASSIGN.PDS

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    51/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 46 of 49

    Step 2 : Save the program and compile using TRNGCOB

    Step 3 : Code the following JCL in a member TXXXJC05

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    52/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 47 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 employeeid

    Member for JCL :TXXXJC05

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    53/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    ER/CORP/CRS/LA01/007 Version No. 3.0 48 of 49

    Assignment 6: Understanding String Handling Verbs

    Objective:To learn how to use the various string handling verbs

    Problem Description:

    Develop a modular COBOL program to perform the following stringhandling functions using INSPECT, STRING and UNSTRINGEvery functionality has to be defined in separate paragraphsEach paragraph has to be called through PERFORM statement from themain paragraphDeclare a string with value EDUCATION AND RESEARCHUse INSPECT Verb to :

    o Count the number of occurrences of A and E in the stringo Replace the character 'A' by 'Z' before the first occurrence of O.o Replace all the characters 'E' by 'M' occurring before 'D'.

    Declare 3 strings with values and PICTURE Clauses as shown below :Mainframes PIC A(20)

    Supports PIC A(12)

    Virtual Storage PIC A(30)

    Use STRING Verb with POINTER and OVERFLOW option to display thefollowing strings in spool :

    Mainframes Supports Virtual Storage

    *********Mainframes Supports virtual storage

    (* denotes blanks)

    Declare a string with value Corporate Training Center - Infosys

    Technologies Limited, MysoreUse UNSTRING Verb to display the following strings in spool :

    Corporate Training Center

    Infosys Technologies Limited

    Mysore

    Estimated time: 60 mins.

    Summary of this assignment:

    How to use STRING and UNSTRING Verbs to concatenate and split the strings How to use INSPECT verb to count the number of occurrence of the character and to

    replace characters in a given string

  • 7/27/2019 LabGuide_COBOL_LA01_LC.pdf

    54/54

    Infosys Technologies Limited Lab Guide for COBOL Programming

    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

    idMember for JCL :TXXXJC06

    Assignment 7: Exercises for Self Review

    1. What is the difference between the LEADING and FIRST phrase used with the INSPECTstatement?2. Predict the output of the following code snippet

    IDENTIFICATION DIVISION.PROGRAM-ID. NEWSTR.DATA DIVISION.

    WORKING-STORAGE SECTION.01 WS-FSTR PIC X(20).01 WS-SSTR PIC X(35).01 WS-TSTR PIC X(15).

    PROCEDURE DIVISION.A000-MAIN-PARA.

    MOVE INFOSYS LIMITED TO WS-FSTRMOVE MYSORE TO WS-SSTR

    STRING WS-FSTR, WS-SSTR INTO WS-TSTRDISPLAY WS-TSTR

    STOP RUN.3. What is the value of WS-COUNT in the following INSPECT statement

    IDENTIFICATION DIVISION.PROGRAM-ID. NEWSTR1.DATA DIVISION.WORKING-STORAGE SECTION.

    01 WS-FSTR PIC X(20).01 WS-COUNT PIC 9(03).

    PROCEDURE DIVISION.

    A000-MAIN-PARA.MOVE GEC INFOSYS MYSORE TO WS-FSTRINSPECT WS-FSTR TALLYING WS-COUNT FOR ALL E

    DISPLAY WS-COUNT