Tuesday, January 24, 2012

PROGRAM TO CREATE SEQUENTIAL FILE

       IDENTIFICATION DIVISION.
       PROGRAM-ID "EMPLOYEE".
       AUTHOR "DEEPAK".
       DATE-WRITTEN 18/01/2012.
       DATE-COMPILED 18/01/2012.
       
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER P4.
       OBJECT-COMPUTER P4.
      
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
       SELECT EMPLOYEE ASSIGN TO DISK ORGANIZATION IS SEQUENTIAL
       ACCESS MODE IS SEQUENTIAL.
       
       DATA DIVISION.
       FILE SECTION.
       FD EMPLOYEE
           LABEL RECORDS ARE STANDARD 
  VALUE OF FILE-ID IS "EMP.DAT".
       01 EMP-INFO.
           02 EMP-ID   PIC   9(6).
  02 EMP-NAME PIC X(20).
  02 EMP-DESIG PIC X(10).
  02 EMP-SAL  PIC 9(5)V99.
       WORKING-STORAGE SECTION.
       77 ANS PIC X.
       
       PROCEDURE DIVISION.
       OPEN OUTPUT EMPLOYEE.
       PARA-1.
           DISPLAY "ENTER THE EMPLOYEE ID".
  ACCEPT EMP-ID.
  DISPLAY "ENTER THE NAME OF EMPLOYEE".
  ACCEPT EMP-NAME.
  DISPLAY "ENTER THE DESIGNATION".
  ACCEPT EMP-DESIG.
  DISPLAY "ENTER THE SALARY".
  ACCEPT EMP-SAL.
  WRITE EMP-INFO.
  DISPLAY "DO U WANT TO CONTINUE...Y/N?".
  ACCEPT ANS.
  IF ANS="Y" GO TO PARA-1.
       END-PARA.
       CLOSE EMPLOYEE.
       DISPLAY "--------------------------------------------------".
       DISPLAY "EMP-ID  EMP-NAME     EMP-DESIGNATION  EMP-SALARY ".
       DISPLAY "--------------------------------------------------".
       OPEN INPUT EMPLOYEE.
        READ-PARA.
           READ EMPLOYEE AT END GO TO STOP-PARA.
  DISPLAY  EMP-ID "   "   EMP-NAME EMP-DESIG EMP-SAL.
       END-PARA.
       GO TO READ-PARA.
       STOP-PARA.
       CLOSE EMPLOYEE.
       STOP RUN.
          
     
         
       
       
     

No comments:

Post a Comment