Home   Easy-Code    Forum  Updater 
Twitter Facebook



Program to eliminate the duplicate records from a file using cobol

Critics Rating:

Users Rating:

* PROGRAM TO ELIMINATE THE DUPLICATE RECORDS FROM A FILE.

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

   IDENTIFICATION DIVISION.

   PROGRAM-ID.

   ENVIRONMENT DIVISION.

   INPUT-OUTPUT SECTION.

   FILE-CONTROL.

      SELECT DATAFILE ASSIGN TO DISK

      ORGANIZATION IS LINE SEQUENTIAL.



      SELECT SORTFILE ASSIGN TO DISK

      ORGANIZATION IS LINE SEQUENTIAL.

   DATA DIVISION.

   FILE SECTION.

   FD DATAFILE

      LABEL RECORDS ARE STANDARD

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

   01 SORTING.

    02 F PIC X(5).

    02 NAM PIC X(10).

    02 F PIC X(5).

    02 SNO PIC 9(3).

   FD SORTFILE

      LABEL RECORDS ARE STANDARD

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

   01 SORTS.

    02 F PIC X(5).

    02 SNAM PIC X(10).

    02 F PIC X(5).

    02 SSNO PIC 9(3).

   WORKING-STORAGE SECTION.

   77 EOF PIC A.

   PROCEDURE DIVISION.

   MAIN-PARA.

      OPEN EXTEND DATAFILE.

      DISPLAY "DO YOU WANT TO INSERT THE RECORD(Y/N)".

      ACCEPT EOF.

   PERFORM X-PARA UNTIL EOF = "N".

      CLOSE DATAFILE.

      MOVE "Y" TO EOF.

      OPEN INPUT DATAFILE.

      OPEN OUTPUT SORTFILE.

      PERFORM Y-PARA UNTIL EOF = "N".

      CLOSE DATAFILE.

      STOP RUN.

   X-PARA.

      DISPLAY (1 , 1) ERASE.

      DISPLAY "ENTER THE STUDENT NAME".

      ACCEPT NAM.

      DISPLAY "ENTER THE ROLLNO".

      ACCEPT SNO.

      DISPLAY "DO YOU WANT TO CONTINUE(Y/N)?".

      ACCEPT EOF.

   Y-PARA.

      READ DATAFILE RECORD AT END MOVE "N" TO EOF.

      IF (EOF NOT = "N")

      

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.