Home   Easy-Code    Forum  Updater 
Twitter Facebook



Program to read a text file and count all the occurences of a particular word.(not possible). program on modification and deletion of records in indexed files. using cobol

Critics Rating:

Users Rating:

* PROGRAM TO READ A TEXT FILE AND COUNT ALL THE OCCURENCES OF A

* PARTICULAR WORD.(NOT POSSIBLE).

* PROGRAM ON MODIFICATION AND DELETION OF RECORDS IN INDEXED FILES.

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

   IDENTIFICATION DIVISION.

   PROGRAM-ID.

   ENVIRONMENT DIVISION.

   INPUT-OUTPUT SECTION.

   FILE-CONTROL.

      SELECT DATAFILE ASSIGN TO DISK

      ORGANIZATION IS INDEXED

      ACCESS MODE IS RANDOM

      RECORD KEY IS ICOD.

   DATA DIVISION.

   FILE SECTION.

   FD DATAFILE

      LABEL RECORDS ARE STANDARD

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

   01 STOCK-REC.

    02 ICOD PIC 9(3).

    02 F PIC X(10).

    02 NAME PIC X(15).

    02 F PIC X(10).

    02 COST PIC 9(4)V99.

    02 F PIC X(10).

    02 STOK PIC 9(5).

   WORKING-STORAGE SECTION.

   77 C PIC 9.

   PROCEDURE DIVISION.

   MAIN-PARA.

      OPEN I-O DATAFILE.

      DISPLAY (1 , 1) ERASE.

      DISPLAY (7 , 30) "1.MODIFY.".

      DISPLAY (9 , 30) "2.DELETE.".

      DISPLAY (11 , 30) "ENTER CHOICE : ".

      ACCEPT C.

      IF (C = 1)

       PERFORM X-PARA

      ELSE

      IF (C = 2)

       PERFORM Y-PARA

      ELSE

       DISPLAY (13 , 30) "WRONG ENTRY".

      CLOSE DATAFILE.

      STOP RUN.

   X-PARA.

      DISPLAY (13 , 30) "WHICH RECORD YOU WANT TO MODIFY : ".

      ACCEPT ICOD.

      READ DATAFILE RECORD INVALID KEY

       DISPLAY (15 , 30) "CAN"T READ FILE"

       STOP RUN.

      COMPUTE STOK = STOK + 100.

      REWRITE STOCK-REC.

      DISPLAY (15 , 30) "THE RECORD " ICOD " IS MODIFIED".

   Y-PARA.

      DISPLAY (13 , 30) "WHICH RECORD YOU WANT TO DELETE : ".

      ACCEPT ICOD.

      READ DATAFILE RECORD INVALID KEY

       DISPLAY (15 , 30) "CAN"T READ FILE"

       STOP RUN.

      DELETE DATAFILE.

      DISPLAY (15 , 30) "THE RECORD " ICOD " IS DELETED".

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.