179023774 labguide cobol la01 lc pdf

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

Upload: sharathraj

Post on 22-Nov-2015

26 views

Category:

Documents


2 download

DESCRIPTION

MF

TRANSCRIPT

  • 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

  • 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&[email protected]

  • 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) Comments 0.0 Aug-05 Narasimha

    Murthy/Priya Murali Konareddy

    Initial Draft

    1.0 Sep-06 Murali/ Narasimha Murthy/Priya

    Murali Konareddy

    Incorporated the review comments

    2.0 03-2007 Karthigai Priya G/Fayaz Basha S.K.

    Murali Konareddy

    FP Restructure 2006-2007

    3.0 Sep-2007 Fayaz Basha SK Murali Konareddy / Shashank

    FP Restructure 2006-2007

  • Infosys Technologies Limited Table of Contents

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

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

    ASSIGNMENT 2: UNDERSTANDING WRITE OPERATION OF A PS FILE ........................................................ 17

    ASSIGNMENT 3: APPENDING RECORDS TO A PS FILE ....................................................................... 18

    ASSIGNMENT 4: UPDATING RECORDS IN A PS FILE ......................................................................... 18

    ASSIGNMENT 5: UNDERSTANDING SEQUENTIAL FILE MANIPULATIONS ...................................................... 19

    ASSIGNMENT 6: EXERCISES FOR SELF REVIEW ............................................................................. 20

    DAY 4 ASSIGNMENTS ................................................................................................... 21

    ASSIGNMENT 1: UNDERSTANDING READ AND WRITE OPERATIONS IN A VSAM KSDS FILE ................................ 21

    ASSIGNMENT 2: UNDERSTANDING THE VSAM KSDS FILE MANIPULATIONS ................................................ 26

    ASSIGNMENT 3: UNDERSTANDING COPY VERB ........................................................................... 27

    ASSIGNMENT 4 : UNDERSTANDING CALL VERB ........................................................................... 31

    ASSIGNMENT 5: CREATION OF MODULAR COBOL PROGRAMS ............................................................. 34

    ASSIGNMENT 6: UNDERSTANDING VSAM KSDS FILE AND PS FILE MANIPULATIONS ........................................ 35

    ASSIGNMENT 7: CREATION OF ALTERNATE INDEX FOR A VSAM KSDS FILE ................................................ 35

    ASSIGNMENT 8: EXERCISES FOR SELF REVIEW ............................................................................. 36

  • Infosys Technologies Limited Table of Contents

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

    DAY 5 ASSIGNMENTS ................................................................................................... 36

    ASSIGNMENT 1: DEMONSTRATION OF ONE DIMENSIONAL ARRAY........................................................... 36

    ASSIGNMENT 2: DEMONSTRATION OF STRING AND UNSTRING VERB .................................................... 38

    ASSIGNMENT 3: DEMONSTRATION OF INSPECT VERB .................................................................... 40

    ASSIGNMENT 4: DEMONSTRATION OF SEARCH ALL VERB ................................................................ 41

    ASSIGNMENT 5: DEMONSTRATION OF REDEFINES AND RENAMES CLAUSES ............................................. 45

    ASSIGNMENT 6: UNDERSTANDING STRING HANDLING VERBS .............................................................. 48

    ASSIGNMENT 7: EXERCISES FOR SELF REVIEW ............................................................................. 49

  • Infosys Technologies Limited Lab Guide for COBOL Programming

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

    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

  • 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 in 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

    Assignment 3: Understanding COBOL Coding Standards

    Objective: To learn how to write a COBOL program according to Infosys Coding 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.

    Estimated time: 30 mins.

  • 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.PDS Member for COBOL program : TXXXCB03, where XXX is last 3 digits of your

    employee id

    Member 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 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

  • 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 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) 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.34

    9(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 459342bb

    9(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 Documents

    folder under DEMOS for the rules to be used Write 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

  • 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 your employee 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 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.

    Data Types Alphabetic Alphanumeric Edited Alphanumeric

    Numeric Numeric non integer

    Edited numeric

    Alphabetic Y Y Y N N N

    Alphanumeric Y Y Y Y* N N

    Edited Alphanumeric

    Y Y Y N N N

    Numeric N Y Y Y Y Y

    Numeric non integer

    N N N Y Y Y

    Edited numeric

    N Y Y Y Y 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:

  • 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 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

    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 Quotient 3. 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 for 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.

  • 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 id Member for JCL : TXXXJC01

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

  • 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 PDS TXXXXX.COBOL.DAY2.ASSIGN.PDS

  • 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 in 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:

  • 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 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: Code the below given program in a member TXXXCB02 in PDS TXXXXX.COBOL.DAY2.ASSIGN.PDS

  • 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 PDS TXXXXX.COBOL.DAY2.ASSIGN.PDS

  • 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 arithmetic verbs, ROUNDED and ON SIZE ERROR clauses

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

    Accept the Basic Salary and HRA from user

  • 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 + 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

    Emp. No : 8900

    Emp. Name : Shastry

    Basic : Rs.xxxx.xx DA : 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.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.

  • 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 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

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

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

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

    employee id Member for JCL : TXXXJC04

  • 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 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

    Estimated time: 20 mins Summary of this assignment:

    How to use accept the inputs from the user and display it on the spool using

    PERFORM.UNTIL verb

    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

    Assignment 6: Using PERFORM.VARYING to generate N elements of Fibonacci 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

  • 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 id Member 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 names 5. Give the syntax of PERFORMVARYING statement

    Day 3 Assignments

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

    Assignment 1: Creation of PS file and understanding the Read Operation 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 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

  • 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 id Member 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 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

    Estimated time: 40 mins.

    Summary of this assignment:

    How to insert the records to a PS file

  • 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.PDS Member for COBOL program : TXXXCB02, where XXX is last 3 digits of your

    employee 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 PS

    file Display 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 your

    employee 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 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

  • 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 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

    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 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 with following structure 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 following structure and insert 6 sample records. (2 for each transaction) 01 TRANS-REC.

    05 TRANS-FLAG PIC X(1).

    05 FILLER PIC X.

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

    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 file

    3. 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 (SELECT

    STATEMENT along with FILE STATUS)

    Physical File name : DOCFILE Logical File name : USRFILE

    File Status variable : WS-FS

  • 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 VSAM KSDS 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 PDS TXXXXX.COBOL.DAY4.ASSIGN.PDS

  • Infosys Technologies Limited Lab Guide for COBOL Programming

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

  • Infosys Technologies Limited Lab Guide for COBOL Programming

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

  • 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 PDS TXXXXX.COBOL.DAY4.ASSIGN.PDS

  • 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 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

  • 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 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 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.VSAM

    PDS : TXXXXX.COBOL.DAY4.ASSIGN.PDS

  • 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 through 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

  • 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 your mainframe id. Press ENTER. Step 4 : The message Member TXXCPY1 created will appear in the right top corner of the screen.

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

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

    Member to be used : TXXXJC03

  • 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

  • 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

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

  • 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 to 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)

  • 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 update 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

    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

  • 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 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

    Assignment 8: Exercises for Self Review

    1. Give the syntax of SELECT statement for a VSAM with ALTERNATE INDEX 2. 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 QSFILE ORGANIZATION IS INDEXED

    ACCESS 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 conventions will 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 PDS TXXXXX.COBOL.DAY5.ASSIGN.PDS

  • 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

  • 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 id Member for JCL : TXXXJC01

    Assignment 2: Demonstration of STRING and UNSTRING Verb

    Objective: To learn how to perform string manipulations using STRING and UNSTRING 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

  • 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 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

  • 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 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

  • 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 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

    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 of 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

  • Infosys Technologies Limited Lab Guide for COBOL Programming

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

  • 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

  • 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 of employee id

    Member for JCL : TXXXJC04

  • 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 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

  • 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

  • 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 employee id

    Member for JCL : TXXXJC05

  • 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 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 Count the number of occurrences of A and E in the string o 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 the following strings in spool :

    Mainframes Supports Virtual Storage

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

    (* denotes blanks)

    Declare a string with value Corporate Training Center - Infosys Technologies Limited, Mysore

    Use 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

  • Infosys Technologies Limited Lab Guide for COBOL Programming

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

    Assignment 7: Exercises for Self Review

    1. What is the difference between the LEADING and FIRST phrase used with the INSPECT

    statement? 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-FSTR

    MOVE MYSORE TO WS-SSTR STRING WS-FSTR, WS-SSTR INTO WS-TSTR

    DISPLAY 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-FSTR

    INSPECT WS-FSTR TALLYING WS-COUNT FOR ALL E

    DISPLAY WS-COUNT STOP RUN.

    4. What is the use of OVERFLOW and POINTER clause in STRING and UNSTRING statements?