COBOL code to create a file using condition name condition


       IDENTIFICATION DIVISION.
       PROGRAM-ID." EMPL".
       AUTHOR."KUNAL"
       DATE-WRITTEN."18/01/12".
       DATE-COMPILED."18/01/12".
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. M8.
       OBJECT-COMPUTER. M8.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
       SELECT EMPL ASSIGN TO DISK
       ORGANIZATION IS SEQUENTIAL
       ACCESS MODE IS SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD EMPL
           LABEL RECORDS ARE STANDARD
           VALUE OF FILE-ID IS "EMPL.DAT".
       01 EMPL-REC.
           02 NAME PIC X(15).
           02 ID1 PIC 9(3).
  02 EXP PIC 99.
           02 QUAL PIC X.
    88 UG VALUE IS "U".
    88 PG VALUE IS "P".
    88 PHD VALUE IS "D".
  02 EYE PIC 9.
    88 BK VALUE IS 1.
    88 BN VALUE IS 2.
    88 BL VALUE IS 3.
    88 OT VALUES ARE 0,4 THRU 9.
  02 QUAL1 PIC X(3).
  02 QUAL2 PIC X.
  02 EYE1 PIC X(5).
  02 EYE2 PIC 9.
       WORKING-STORAGE SECTION.
       77 N PIC X.
       77 A PIC 99 VALUE IS 0.
       77 B PIC 99 VALUE IS 0.
       77 C PIC 99 VALUE IS 0.
       PROCEDURE DIVISION.
       OPEN OUTPUT EMPL.
       GET-PARA.
           DISPLAY "Enter name".
  ACCEPT NAME.
  DISPLAY "Enter ID:".
  ACCEPT ID1.
  DISPLAY "Enter qualification:".
  ACCEPT QUAL2.
  DISPLAY "Enter eye color:".
  ACCEPT EYE2.
  WRITE EMPL-REC.
  DISPLAY "Do u want to continue....PRESS Y".
  ACCEPT N.
  IF N = "Y"
  GO TO GET-PARA.
  END-GET.
  CLOSE EMPL.
  OPEN INPUT EMPL.
  DISPLAY     "---------------------------------------------------".
  DISPLAY "NAME            ID  QUALIFICATION EYE-COLR ".
  DISPLAY "-------------------------------------------------------".
  READ-PARA.
  READ EMPL AT END GO TO END-PARA.
  MOVE QUAL2 TO QUAL.
  IF UG MOVE "UG" TO QUAL1
  ELSE IF PG MOVE "PG" TO QUAL1
  ELSE IF PHD MOVE "PHD" TO QUAL1.
  MOVE EYE2 TO EYE.
  IF BK MOVE "BLACK" TO EYE1
  ELSE IF BN MOVE "BROWN" TO EYE1
  ELSE IF BL MOVE "BLUE" TO EYE1
  ELSE IF OT MOVE "OTHER" TO EYE1.
  IF UG AND BK ADD 1 TO A
  ELSE IF PG AND BN ADD 1 TO B
  ELSE IF PHD AND BL ADD 1 TO C.
      DISPLAY NAME ID1 QUAL1 EYE1.
           
  GO TO READ-PARA.   
  END-PARA.
  DISPLAY "Employee with black eye & UG " A.
  DISPLAY "Employee with brown eye & PG " B.
  DISPLAY "Employee with blue eye & PHD " C.
  CLOSE EMPL.
  STOP RUN.        
Previous
Next Post »