Code for Program to SEARCH PERTICULAR record in Cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. A33.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. PC.
OBJECT-COMPUTER. PC.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT TRAN ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
SELECT IND ASSIGN TO DISK
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS SNO.
DATA DIVISION.
FILE SECTION.
FD TRAN
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "T.DAT".
01 TRAN-REC.
02 SNO-I PIC 99.
02 NAME-I PIC X(6).
FD IND
LABEL RECORD ARE STANDARD
VALUE OF FILE-ID IS "TIND".
01 IND-REC.
02 SNO PIC 99.
02 NAME-IND PIC X(6).
WORKING-STORAGE SECTION.
77 EOF PIC X(3) VALUE "NO".
77 NUM PIC 99 VALUE 0.
PROCEDURE DIVISION.
MAIN-PARA.
OPEN INPUT TRAN OUTPUT IND.
READ TRAN AT END MOVE 'YES' TO EOF.
PERFORM CREA-PARA UNTIL EOF = 'YES'.
CLOSE TRAN IND.
DISPLAY "KEY IN NUMBER TO SERCH : "
ACCEPT NUM
OPEN INPUT IND.
PERFORM PR-PARA.
CLOSE IND.
STOP RUN.
CREA-PARA.
MOVE TRAN-REC TO IND-REC.
WRITE IND-REC INVALID KEY
DISPLAY "DUPLICATE RECORD".
READ TRAN AT END MOVE 'YES' TO EOF.
PR-PARA.
MOVE NUM TO SNO.
READ IND INVALID KEY
DISPLAY 'RECORD NOT FOUND'.
DISPLAY NAME-IND.
INPUT:-
01ABCDEF
02BCDEFG
03KKKKKK
04LLLLLL
05OOOOOO
OUTPUT:-