convert sequential file to relative file



       IDENTIFICATION DIVISION.
       PROGRAM-ID." ENGG. FILE".
       AUTHOR."KUNAL".
       DATE-WRITTEN."19/02/12".
       DATE-COMPILED."19/02/12".
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. M8.
       OBJECT-COMPUTER. M8.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
       SELECT ENGS ASSIGN TO DISK
       ORGANIZATION IS SEQUENTIAL
       ACCESS MODE IS SEQUENTIAL.
       SELECT ENGR ASSIGN TO DISK
       ORGANIZATION IS RELATIVE
       ACCESS MODE IS DYNAMIC
       RELATIVE KEY IS RELKEY.
       DATA DIVISION.
       FILE SECTION.
       FD ENGS
          LABEL RECORDS ARE STANDARD
          VALUE OF FILE-ID IS "ENGS.DAT".
        01 ENGS-REC.
         02 ID1 PIC 9(3)B.
         02 NAME1 PIC X(13)B.
02 EXP1 PIC 99B.
         02 ADD1 PIC X(15).
       FD ENGR
         LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "ENGR.DAT".
        01 ENGR-REC.
         02 ID2 PIC 999B.
02 NAME2 PIC X(13)B.
02 EXP2 PIC 99B.  
02 ADD2 PIC X(15).
       WORKING-STORAGE SECTION.
       77 RELKEY PIC 99.
       77 COUNT1 PIC 99 VALUE IS 0.
       77 ANS PIC X.     
       PROCEDURE DIVISION.
  OPEN OUTPUT ENGS.
  START-PARA.
   
           DISPLAY(1,10) "ENTER ID.".
           ACCEPT(1,30) ID1.
   DISPLAY(2,10)"ENTER NAME".
   ACCEPT(2,30) NAME1.
   DISPLAY(3,10) "ENTER EXPERIENCE".
   ACCEPT(3,30) EXP1.
   DISPLAY(4,10) "ENTER ADDRESS".
   ACCEPT(4,30) ADD1.
   WRITE ENGS-REC. 
   DISPLAY(5,10) "TO CONTINUE..PRESS Y".
   ACCEPT(6,30) ANS.
   IF ANS = "Y"
   GO TO START-PARA.
   CLOSE ENGS.
  OPEN INPUT ENGS.
  OPEN OUTPUT ENGR.
  GET-PARA.
   READ ENGS AT END GO TO L-PARA.
   DISPLAY(8,3) "ENTER RECORD NO."
   ACCEPT(8,30) RELKEY.
   MOVE ID1 TO ID2.
   MOVE NAME1 TO NAME2.
            MOVE EXP1 TO EXP2.
   MOVE ADD1 TO ADD2.
   WRITE ENGR-REC.
   GO TO GET-PARA.
   L-PARA.
   CLOSE ENGS,ENGR.
   OPEN INPUT ENGR.
   DISPLAY(9,1) "--------------------------------------------".
   DISPLAY(10,1) "ID NAME         EXP ADDRESS".
   DISPLAY(11,1) "-----------------------------------------".
            DISPLAY " ".   
   READ-PARA.
   READ ENGR NEXT RECORD AT END GO TO LAST-PARA.
     IF EXP2 = "02" AND ADD2 = "CHANDRAPUR"
     ADD 1 TO COUNT1.  
   DISPLAY ID2 NAME2 EXP2 ADD2.
   GO TO READ-PARA.
   LAST-PARA.
   DISPLAY "ENGG FROM C.PUR HAVING EXP 2 YEARS=" COUNT1.
   CLOSE ENGR.
  
   STOP RUN.  
    
          
       
Previous
Next Post »