Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program to describes the use of Tables with INPUT Clause

Posted By: Giselle Miller     Category: Cobol     Views: 1710

Write a program to describes the use of Tables with INPUT Clause.

Code for Program to describes the use of Tables with INPUT Clause in Cobol

       IDENTIFICATION DIVISION.
        PROGRAM-ID. Table1.

       ENVIRONMENT DIVISION.

        CONFIGURATION SECTION.
         SOURCE-COMPUTER. IBM-PC.
         OBJECT-COMPUTER. IBM-PC.

        INPUT-OUTPUT SECTION.

         FILE-CONTROL.
           SELECT TABLE-FILE ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.

           SELECT EMP-IN-FILE ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.

           SELECT EMP-OUT-FILE ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.

       DATA DIVISION.

        FILE SECTION.
         FD TABLE-FILE
           VALUE OF FILE-ID IS "TableEmp.ind".

         01 table-rec.
            05 t-emp-desig pic x.
            05 filler pic x.
            05 t-inc-per pic 99.

         FD EMP-IN-FILE
           VALUE OF FILE-ID IS "Emp.dat".
         01 emp-in-rec.
            05 emp-name pic x(7).
            05 filler pic xx.
            05 emp-desig pic x.
            05 emp-salary pic 99999.

         FD EMP-OUT-FILE
           VALUE OF FILE-ID IS "Emp.rpt".
         01 emp-out-rec piC x(80).

        WORKING-STORAGE SECTION.

        01 table-entries occurs 3 times.
           05 tABLE-emp-desig pic x.
           05 filler pic x.
           05 tABLE-inc-per pic 99.

       01 emp-entries.
          05 temp-emp-name pic x(7).
          05 filler PIC xx.
          05 temp-emp-desig pic x.
          05 filler PIC xx.
          05 temp-emp-basic pic 9(5).
          05 filler PIC xx.
          05 temp-emp-inc-per pic 99.
          05 filler PIC xx.
          05 temp-emp-inc pic 9(5).

        77 eof pic x value'N'.
        77 ind pic 9 value 1.

       PROCEDURE DIVISION.
         begin.
           OPEN INPUT TABLE-FILE
                      EMP-IN-FILE
               OUTPUT EMP-OUT-FILE.

           PERFORM GET-TABLE-ENTRIES-PARA.
           PERFORM EMP-UPDATE-PARA.

           CLOSE TABLE-FILE
                 EMP-IN-FILE
                 EMP-OUT-FILE.
           STOP RUN.

         GET-TABLE-ENTRIES-PARA.
           perform varying ind from 1 by 1 until ind >3
            read TABLE-FILE
             at end continue
             not at end perform move-table-entries-para
            end-read
           end-perform.

         move-table-entries-para.
           move t-emp-desig to TABLE-EMP-desig (IND)
           move t-inc-per to TABLE-inc-per (IND).

         EMP-UPDATE-PARA.
           PERFORM UNTIL EOF = 'Y'
            READ EMP-IN-FILE
             AT END MOVE 'Y' TO EOF
             NOT AT END PERFORM CHECK-UPDATE-PARA
           END-PERFORM.

         CHECK-UPDATE-PARA.
           MOVE EMP-NAME TO TEMP-EMP-NAME.
           MOVE EMP-DESIG TO TEMP-EMP-DESIG.
           MOVE EMP-SALARY TO TEMP-EMP-BASIC.
           MOVE 1 TO IND.
           PERFORM VARYING IND FROM 1 BY 1 UNTIL IND > 3
            IF EMP-DESIG = TABLE-EMP-DESIG (IND)
              MOVE TABLE-INC-PER (IND) TO TEMP-EMP-INC-PER 
              COMPUTE TEMP-EMP-INC = EMP-SALARY + (EMP-SALARY * TEMP-EMP-INC-PER)/100
            END-IF
           END-PERFORM.
           PERFORM WRITE-PARA.

         WRITE-PARA.
           WRITE EMP-OUT-REC FROM EMP-ENTRIES.


***************************
INPUT FILE 1 - TABLEEMP.IND             
***************************
M 10
C 05
P 05

**********************
INPUT FILE 2 - EMP.DAT             
**********************

Prem   M10000
Jinal  C05000
Harsh  C05000
Nitin  P03000


*********************
OUTPUT FILE - EMP.RPT             
*********************

Prem     M  10000  10  11000
Jinal    C  05000  05  05250
Harsh    C  05000  05  05250
Nitin    P  03000  05  03150
  
Share: 


Didn't find what you were looking for? Find more on Program to describes the use of Tables with INPUT Clause Or get search suggestion and latest updates.

Giselle Miller
Giselle Miller author of Program to describes the use of Tables with INPUT Clause is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!