Home   Easy-Code    Forum  Updater 
Twitter Facebook



Program to print the required details of a particular record in an employee file by using eno as a key using cobol

Critics Rating:

Users Rating:

* PROGRAM TO PRINT THE REQUIRED DETAILS OF A PARTICULAR RECORD IN AN

*   EMPLOYEE FILE BY USING ENO AS A KEY.

********************************************************************

   IDENTIFICATION DIVISION.

   PROGRAM-ID.

   ENVIRONMENT DIVISION.

   INPUT-OUTPUT SECTION.

   FILE-CONTROL.

      SELECT DATAFILE ASSIGN TO DISK

      ORGANIZATION IS LINE SEQUENTIAL.

   DATA DIVISION.

   FILE SECTION.

   FD DATAFILE

      LABEL RECORDS ARE STANDARD

      VALUE OF FILE-ID IS "EMP.DAT".

   01 EMP.

    02 ENO PIC 9(3).

    02 F PIC X(5).      

    02 NAM PIC X(10).

    02 F PIC X(5).

    02 HRA PIC 9(3).

    02 F PIC X(5).

    02 EDA PIC 9(3).

    02 F PIC X(5).

    02 BAS PIC 9(5).

    02 F PIC X(5).

    02 TOT PIC 9(5).

   WORKING-STORAGE SECTION.

   77 NUM PIC 9(3).

   77 EOF PIC 9 VALUE 0.

   77 P PIC ZZ999.99.

   PROCEDURE DIVISION.

   MAIN-PARA.

      OPEN INPUT DATAFILE.

      DISPLAY "ENTER THE EMPLOYEE NUMBER TO BE SEARCHED".

      ACCEPT NUM.

      READ DATAFILE RECORD AT END MOVE 1 TO EOF.

      PERFORM X-PARA UNTIL EOF = 1.

      DISPLAY "THERE IS NO RECORD WITH THE NUMBER "

               "YOU HAVE ENTERED".

      CLOSE DATAFILE.

      STOP RUN.

   X-PARA.

      IF (NUM = ENO)

       DISPLAY "EMPLOYEE NAME : " NAM

       MOVE HRA TO P

       DISPLAY "HOUSE RENT ALLOWANCE :" P

       MOVE EDA TO P

       DISPLAY "DEARENCE ALLOWANCE :" P

       MOVE BAS TO P

       DISPLAY "EMPLOYEE BASIC SALARY :" P

       MOVE TOT TO P

       DISPLAY "EMPLOYEE TOTAL SALARY :" P

       CLOSE DATAFILE

       STOP RUN

      ELSE

       READ DATAFILE RECORD AT END MOVE 1 TO EOF.

Courtesy, Source, References & Regards: Kishore AVGK

While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright@2009-2011 by KuGuNi.com. All Rights Reserved.