0% found this document useful (0 votes)
243 views

Create & Process A Vsam-Esds Sequential File in Cobol

The document describes a COBOL program that creates and processes a VSAM-ESDS/sequential file. The program allows the user to select from six options: 1) search for a record, 2) insert a new record, 3) rewrite an existing record, 4) delete a single record, 5) delete all records, or 6) display all records. Based on the user's selection, the program will open and perform the appropriate input, output, or update operation on the VSAM file.

Uploaded by

sati1987
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
243 views

Create & Process A Vsam-Esds Sequential File in Cobol

The document describes a COBOL program that creates and processes a VSAM-ESDS/sequential file. The program allows the user to select from six options: 1) search for a record, 2) insert a new record, 3) rewrite an existing record, 4) delete a single record, 5) delete all records, or 6) display all records. Based on the user's selection, the program will open and perform the appropriate input, output, or update operation on the VSAM file.

Uploaded by

sati1987
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

ESDS FILE MANIPULATION AIM: CREATE & PROCESS A VSAM-ESDS/SEQUENTIAL FILE IN COBOL ****** ***************************** Top of Data *******************************

******* IDENTIFICATION DIVISION. PROGRAM-ID. MACESDS. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT MAC ASSIGN TO AS-ESDSFILE. DATA DIVISION. FILE SECTION. FD MAC. 01 MREC. 05 MNO PIC 9(5). 05 MNAME PIC X(10). WORKING-STORAGE SECTION. 01 A PIC 99 VALUE ZERO. 01 B PIC 9(5) VALUE ZERO. PROCEDURE DIVISION. 0001. ***** DISPLAY "ENTER 1.SEARCH/2.INSERT/3.REWRITE/4.DE L/5.DEL ALL 6.DISP". ACCEPT A. IF A = 1 GO 1SEARCH ELSE IF A = 2 GO 2WRITE ELSE IF A = 3 GO 3REWRITE ELSE IF A = 4 GO 4DELETE ELSE IF A = 5 GO 5DELALL ELSE IF A = 6 GO 6DISPLAY ELSE DISPLAY "INVALID INPUT" GO 0001. STOP RUN. 1SEARCH. OPEN INPUT MAC. *****DISPLAY "ENTER RECORD NO TO BE SEARCHED". ACCEPT B. 0002. READ MAC AT END DISPLAY B "NOT FOUND", GO 000X. IF B = MNO DISPLAY "FOUND " MNO ":" , DISPLAY " AT POS:" A " FOR NAME: " MNAME, GO 000X. ADD 1 TO A. GO TO 0002. 2WRITE. OPEN EXTEND MAC. ACCEPT MNO. ACCEPT MNAME. WRITE MREC. GO 000X. 3REWRITE. OPEN I-O MAC. *****DISPLAY "ENTER RECORD NO TO BE REWRITED". ACCEPT B. 0003. READ MAC AT END DISPLAY "MNO NOT FOUND" G O 000X. IF MNO NOT = B GO 0003.

ACCEPT MNO. ACCEPT MNAME. REWRITE MREC. GO 000X. 4DELETE. OPEN I-O MAC. *****DISPLAY "ENTER RECORD NO TO BE DELETED". ACCEPT B. 0004. READ MAC AT END DISPLAY "MNO NOT FOUND" G O 000X. IF MNO NOT = B GO 0003. MOVE SPACES TO MREC. REWRITE MREC. GO 000X. 5DELALL. *****DISPLAY "SEQ FILE!SO ALL RECORDS ARE DELETED". *****DISPLAY "ARE YOU SURE(1/0)". ACCEPT A. IF A = 1 OPEN OUTPUT MAC DISPLAY "RECORDS DELETED" GO 000X ELSE GO 000X. 6DISPLAY. OPEN INPUT MAC. 0005. READ MAC AT END GO 000X. DISPLAY MNO, " ", MNAME. GO 0005. 000X. CLOSE MAC. *****DISPLAY "CONTINUE?1/0". ACCEPT A. IF A = 0 STOP RUN ELSE GO 0001. ****** **************************** Bottom of Data ***************************** ******* //Compatible with all compilers & version .Remove comments for PC Cobol only ALLOWED OPERATIONS

INPUT: 1. 2. 3. n 4. 5. 6. SEARCH <== To find the position of an element with in the file WRITE / APPEND (automatic) <== To insert/append a record to a file REWRITE <== To rewrite a new record over an element's record positio DELETE DELETE ALL DISPLAY ALL <== To delete a record (in seq file, yes!) <== To delete all records from the file <== To display / view all the records from the file

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy