Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

PROGRAM TO SEARCH THE RECORDS FROM FILE

Posted By: Corey Brown     Category: Cobol     Views: 7684

PROGRAM TO SEARCH THE RECORDS FROM FILE.

Code for PROGRAM TO SEARCH THE RECORDS FROM FILE in Cobol

      IDENTIFICATION DIVISION.
         PROGRAM-ID. SRCH.

       ENVIRONMENT DIVISION.
         FILE-CONTROL.
           SELECT TRAN-FILE ASSIGN TO "MEMBER.TXT"
           ORGANIZATION IS LINE SEQUENTIAL.

       DATA DIVISION.
        FILE SECTION.
         FD TRAN-FILE
           LABEL RECORDS ARE STANDARD.
         01 TRAN-REC.
          03 RNO   PIC 999.
          03 RNAME PIC X(12).

        WORKING-STORAGE SECTION.
         01 TBL.
           03 ENTRIES OCCURS 10 TIMES INDEXED BY IDX.
             05 RNO1   PIC 999.
             05 RNAME1 PIC X(12).
         01 EOF PIC X VALUE "N".
         01 VAL PIC 999.
         01 X PIC 9 VALUE 0.
       PROCEDURE DIVISION.
        BEGIN.
          OPEN INPUT TRAN-FILE.
          
          PERFORM VARYING IDX FROM 1 BY 1 UNTIL IDX>7
           READ TRAN-FILE
            AT END DISPLAY "ERROR"
            NOT AT END
                MOVE RNO TO RNO1(IDX)
                MOVE RNAME TO RNAME1(IDX)
           END-READ
          END-PERFORM.
          CLOSE TRAN-FILE.

          DISPLAY "NO:" WITH NO ADVANCING.
          ACCEPT VAL.

          SET IDX TO 1
          SEARCH ENTRIES
              WHEN RNO1(IDX)=VAL
                DISPLAY RNAME1(IDX)
          END-SEARCH.
          STOP RUN.
  
Share: 


Didn't find what you were looking for? Find more on PROGRAM TO SEARCH THE RECORDS FROM FILE Or get search suggestion and latest updates.

Corey Brown
Corey Brown author of PROGRAM TO SEARCH THE RECORDS FROM FILE is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!