Cobol Tutorial

 
 
 

Basic Programming

Print mark sheet of a student with grades Use of Redefine clause Create marksheet of student Use of leading and trailing Sequential search Class condition Student detail management using indexed file

Search Programs

Enter value is alphabetic,numeric,alphanumeric Find yearly depreciation Unstring word Find smallest quotation for given item Write records reside in i/p file- show on screen Sum of series 1 + 1/4 + 1/9 Using sign test for numeric value Draw polygon Use of EVALUATE clause Count number of char Date manipulation Bubble sort DOS standard o/p device Create the index file

String Programs

Includes external source file in current file Gross salary, deduction, net salary of employee Count character for no of times in input string Display triangle of numbers FILE Read Operation Add two numbers Generate sales report item wise Divides one or more operands by another IF-ELSE Clause Group wise stock summary Attendence Report of Employees SORTING Operation Add 2 or more operands and stores result Relative file - insertion,deletion,updation, print Describe Functionality of table by using File Fahrenheit into temperature - C = (5/9) * (f - 32) Use of Control Break clause Print employee detail Draws an ellipse or a circle Binary search using files Generating date and time

General Programs

Evaluate gender from user and print Display input number is prime or not Display on printer message entered by user Displays message entered by user on printer Merging two files in a single file Generate arithmetic operation - evaluate clause Print account report Use of Sign clause Create attendence sheet Displays on printer - divide operation quotient Binary search on student name, print roll number job appl checking candidate is eligible or not Read data from input file and move to output file

Mathematical Program

Print bill report Purchase and rebate amount payslip Example of string and unstring Describe Functionality of two dimension table Insert, delete, update, view in index file Display the pattern of square School management system Converting integer to its number of words Use of move clause for numeric values Use multiple array Inventory transactions Sort records of file Displays alphanumeric char on screen graphic mode Student details using relative file

Sorting Programs

Store content in file,record of field - other file Calculate Total percentage Classfor each student Edit character Display pattern of numbers in reverse pattern User input data and stores it in to the file Multiplication table Generate sales register Draw a line Use of Tables with INPUT clause Check student is pass or fail i/p result from user Calculate monthly sales amount -sequential access Sescribes how to use Sort technique Declares data to the compiler Input record into file using extend mode

Clause

Describe Functionality of Relative File Print addition of two nos and sum is third or not Use of perform verbs Bank Report depending upon user choice Create result statement for given semester Search name from file display roll no of student Generating julian date Evaluates arithmetic expression - stores result Use of evaluate clause Describe use of IF CONDITION and PRINT Calculate Total percentage Class for each student Displays alphanumeric character in graphics mode Reads in states until end of data Read student details from file - read operation Merge 2 files with students records Print presence report based on provided data Use of Inspect clause Check entered date is valid birth date or not Draws rectangle filled with one color Search perticular record Find age from accepted date from user

File Programs

Check two same condition name is allow or not Arithmetic operations add,sub,div and mul Display on Console a message entered by user Display message entered by user on console Generate student mark sheet using file r/w op Check if a number is a fibonacci or not
 
 
        IDENTIFICATION DIVISION.
        PROGRAM-ID. EMPLOYEE.

        ENVIRONMENT DIVISION.
        INPUT-OUTPUT SECTION.
        FILE-CONTROL.
                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.

      *    Input file description.  
        FD EMP-IN-FILE LABEL RECORDS ARE STANDARD
                    VALUE OF FILE-ID IS \'EMPL2001.DAT\'.
        01 EMP-REC.
                05 ENO          PIC 9(5).
                05 ENAME        PIC X(25).
                05 EBASIC       PIC 9(4)V99.
                05 EMY.
                        10 MM   PIC 99.
                        10 YY   PIC 99.

      *    Attendence of the 31 days.
                05 EATTEN OCCURS 31 TIMES PIC A.

        FD EMP-OUT-FILE LABEL RECORDS ARE STANDARD        
                   VALUE OF FILE-ID IS \'EMPREC.RPT\'.     
        01 OUT-REC PIC X(120).                   

        WORKING-STORAGE SECTION.

      *    Structure of the header to be printed.  
        01 HEAD1.
                05 FILLER               PIC X(35) VALUE SPACES.
                05 TEXT1                PIC X(25) VALUE 
                                        \'RCC INFO TECH LTD\'.
        01 HEAD2.
                05 FILLER               PIC X(4)   VALUE SPACES.
                05 COL1                 PIC X(5)   VALUE \'EMP.\'.
                05 FILLER               PIC X(2)   VALUE SPACES.
                05 COL2                 PIC X(25)  VALUE \'EMP.\'.
                05 FILLER               PIC X(2)   VALUE SPACES.
                05 COL3                 PIC X(7)   VALUE \'DAILY\'.
                05 FILLER               PIC X(4)   VALUE SPACES.
                05 COL4                 PIC X(8)   VALUE SPACES.
                05 COL5                 PIC X(10)   VALUE \'ATTENDANCE\'.
                05 COL6                 PIC X(7)   VALUE \'DAYS\'.
                05 COL7                 PIC X(5)   VALUE SPACES.
                05 FILLER               PIC X(2)   VALUE SPACES.
                05 COL8                 PIC X(6)   VALUE SPACES.
                05 FILLER               PIC X(2)   VALUE SPACES.
                05 COL9                 PIC X(8)   VALUE SPACES.
                05 FILLER               PIC X(5)   VALUE SPACES.
                05 COL10                PIC X(15)  VALUE \'SALARY\'.

      *    Structure of the actual record to be printed in report.
        01 REC.
                05 FILLER               PIC X(1)   VALUE SPACES.
                05 REC1                 PIC Z(5).
                05 FILLER               PIC X(2)   VALUE SPACES.
                05 REC2                 PIC X(25).
                05 FILLER               PIC X(4)   VALUE SPACES.
                05 REC3                 PIC ZZZZ.ZZ.
                05 REC-ATTEN OCCURS 6 TIMES PIC Z(7)9.
                05 FILLER               PIC X(5)   VALUE SPACES.
                05 REC5                 PIC ZZ,ZZ,ZZ9.99.

      *   Attendence count of the 6 type of employees.
        01 EMP-ATTEN. 
                05 ATTEN OCCURS 6 TIMES PIC 9(7).

        77 D-LINE       PIC X(120) VALUE ALL \'-\'.
        77 AMT          PIC 9(9)V99.
        77 TSAL         PIC 9(9)V99 VALUE ZERO.
        77 ECOUNT       PIC 99 VALUE ZERO.
        77 I            PIC 99 VALUE ZERO.
        77 EOF          PIC X VALUE \'N\'.


        PROCEDURE DIVISION.

      *   Main procedure to open files and perform operations.
        MAIN-PARA.
                OPEN INPUT  EMP-IN-FILE
                     OUTPUT EMP-OUT-FILE.

                PERFORM HEAD-PARA.
                READ EMP-IN-FILE.
                PERFORM READ-PARA UNTIL EOF = \'Y\'.
                PERFORM FOOTER-PARA.
                PERFORM CLOSE-PARA.

      *    Intialise the total variables by zero.
        INIT-PARA.
                MOVE ZERO TO ATTEN(I).

      *    Para to print the header in the output file.
        HEAD-PARA.
                WRITE OUT-REC FROM HEAD1.
                MOVE \'SALARY STATEMENT\' TO TEXT1.
                WRITE OUT-REC FROM HEAD1.

                WRITE OUT-REC FROM D-LINE.
                WRITE OUT-REC FROM HEAD2.
                MOVE \'NO.\' TO COL1.
                MOVE \'NAME\' TO COL2.
                MOVE \'RATE\' TO COL3.
                MOVE \'PRE\' TO COL4.
                MOVE \'ABS\' TO COL5.
                MOVE \'HDAY\' TO COL6.
                MOVE \'LWP\' TO COL7.
                MOVE \'SICK\' TO COL8.
                MOVE \'LEAVE\' TO COL9.
                MOVE SPACES TO COL10.
                WRITE OUT-REC FROM HEAD2.
                WRITE OUT-REC FROM D-LINE.

      *    Para to read the record and calculate his attendence. 
        READ-PARA.
                ADD 1 TO ECOUNT.
                PERFORM INIT-PARA VARYING I FROM 1 BY 1 UNTIL I > 6.
                PERFORM CALC-PARA VARYING I FROM 1 BY 1 UNTIL I > 31.
                PERFORM WRITE-PARA.
                READ EMP-IN-FILE AT END MOVE \'Y\' TO EOF.

      *    Depending upon the input value increment the attendence type.          
        CALC-PARA.
                IF EATTEN(I) = \'P\'
                        ADD 1 TO ATTEN(1)
                ELSE IF EATTEN(I) = \'A\'
                        ADD 1 TO ATTEN(2)
                ELSE IF EATTEN(I) = \'H\'
                        ADD 1 TO ATTEN(3)
                ELSE IF EATTEN(I) = \'W\'
                        ADD 1 TO ATTEN(4)
                ELSE IF EATTEN(I) = \'S\'
                        ADD 1 TO ATTEN(5)
                ELSE IF EATTEN(I) = \'E\'
                        ADD 1 TO ATTEN(6).

      *    Write the output record to the file.
        WRITE-PARA.
                MOVE ENO TO REC1.
                MOVE ENAME TO REC2.
                MOVE EBASIC TO REC3.
                PERFORM MOVE-PARA VARYING I FROM 1 BY 1 UNTIL I > 6.
                IF ATTEN(1) > 26
                        COMPUTE AMT = (EBASIC * 26) + 
                        ((1.5 * EBASIC) * (ATTEN(1) - 26))
                ELSE        
                        COMPUTE AMT = (EBASIC * 26).

                ADD AMT TO TSAL.
                MOVE AMT TO REC5.
                WRITE OUT-REC FROM REC.

      *    Move unedited attendence to edited one.
        MOVE-PARA.
                MOVE ATTEN(I) TO REC-ATTEN(I).

      *    Para to print the footer report in the output file.
        FOOTER-PARA.
                WRITE OUT-REC FROM D-LINE.

                MOVE SPACES TO REC.
                MOVE \'TOTAL SALARY\' TO REC2.
                MOVE TSAL TO REC5.
                WRITE OUT-REC FROM REC.

                MOVE SPACES TO REC.
                MOVE \'NO. OF EMPLOYEES    :=> \' TO REC2.
                MOVE ECOUNT TO REC-ATTEN(1).
                WRITE OUT-REC FROM REC.
                WRITE OUT-REC FROM D-LINE.

      *    Para to close all files and end the program.          
        CLOSE-PARA.        
                CLOSE EMP-IN-FILE EMP-OUT-FILE.
                STOP RUN.

 
 
Didn't find what you were looking for? Find more on Program to create a Attendence Report of Employees