COBOL program to create sequential file


       IDENTIFICATION DIVISION.
       PROGRAM-ID." SEQUENTIAL FILE".
       AUTHOR."KUNAL"
       DATE-WRITTEN."16/01/12".
       DATE-COMPILED."16/01/12".
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. M8.
       OBJECT-COMPUTER. M8.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
       SELECT EMP ASSIGN TO DISK
       ORGANIZATION IS SEQUENTIAL
       ACCESS MODE IS SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD EMP
           LABEL RECORDS ARE STANDARD
           VALUE OF FILE-ID IS "EMP.DAT".
       01 EMP-REC.
           02 EMP-ID PIC Z9(5).
           02 NAME PIC X(20).
           02 DESG PIC X(14).
           02 SAL PIC 9(5)V99.
       WORKING-STORAGE SECTION.
       77 N PIC X.
       PROCEDURE DIVISION.
       OPEN OUTPUT EMP.
       GET-PARA.
           DISPLAY "Enter employee id:".
  ACCEPT EMP-ID.
  DISPLAY "Enter employee name:".
  ACCEPT NAME.
  DISPLAY "Enter designation:".
  ACCEPT DESG.
  DISPLAY "Enter salary:".
  ACCEPT SAL.
  WRITE EMP-REC.
  DISPLAY "Do u want to continue....PRESS Y".
  ACCEPT N.
  IF N = "Y"
  GO TO GET-PARA.
  END-GET.
  CLOSE EMP.
  OPEN INPUT EMP.
  DISPLAY "-------------------------------------------------------".
  DISPLAY "EMP_ID    NAME         DESIGNATION      SALARY ".
  DISPLAY "-------------------------------------------------------".
  READ-PARA.
  READ EMP AT END GO TO END-PARA.
  DISPLAY EMP-ID  NAME DESG SAL.
  GO TO READ-PARA.
  END-PARA.
  CLOSE EMP.
  STOP RUN.     

Previous
Next Post »