Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

STUDENT DETAILS MANAGEMENT USING INDEXED FILE

Posted By: Adalrik Fischer     Category: Cobol     Views: 6103

PROGRAM TO MANAGEMENT STUDENT DETAILS USING INDEXED FILE.

Code for STUDENT DETAILS MANAGEMENT USING INDEXED FILE in Cobol

       IDENTIFICATION DIVISION.
        PROGRAM-ID. STUDENT.

       ENVIRONMENT DIVISION.
        INPUT-OUTPUT SECTION.
        FILE-CONTROL.
         SELECT STU-FILE ASSIGN TO DISK
         ORGANIZATION IS INDEXED
         ACCESS MODE IS RANDOM
         RECORD KEY IS SEM-NO
         ALTERNATE RECORD KEY IS STU-NO.

       DATA DIVISION.
        FILE SECTION.
        FD STU-FILE
          LABEL RECORDS ARE STANDARD
          VALUE OF FILE-ID IS "STUDENT.MST".
          01 STU-MST-REC.
           02 SEM-NO     PIC 9.
           02 STU-NO     PIC 99.
           02 STU-NAME   PIC X(20).
           02 GENDER     PIC X.

        WORKING-STORAGE SECTION.
          01 MORE-RECORDS     PIC X VALUE 'Y'.
          01 DASH-LINE   PIC X(80) VALUE ALL "=".
          01 CHOICE1      PIC 9.
          01 EOF PIC X VALUE "Y".
      *    01 CH          PIC 9.
          01 WS-STU-REC.
           02 WS-SEM-NO  PIC 9.
           02 WS-STU-NO  PIC 99.
           02 WS-STU-NAME PIC X(20).
           02 WS-GENDER  PIC X.

       PROCEDURE DIVISION.
        MAIN-PARA.
          OPEN I-O STU-FILE
          PERFORM CHOICE-PARA  UNTIL CHOICE1=4
          CLOSE STU-FILE
          STOP RUN.


        CHOICE-PARA.
          
          DISPLAY DASH-LINE
          DISPLAY "      STUDENT INFORMATION ".
          DISPLAY DASH-LINE.
          DISPLAY "1 ) ADD NEW STUDENT".
          DISPLAY "2 ) VEW STUDENT RECORD ".
          DISPLAY "3 ) DELETE STUDENT RECORD".
          DISPLAY "4 ) VIEW ALL RECORDS ".
          DISPLAY "5 ) EXIT ".
          DISPLAY " ENTER CHOICE " WITH NO ADVANCING.
          ACCEPT CHOICE1.

          EVALUATE CHOICE1
               WHEN 1 PERFORM ADD-PARA
               WHEN 2 PERFORM VEIW-PARA
               WHEN 3 PERFORM DELETE-PARA
               WHEN 4 PERFORM VEIW-ALL
               WHEN 5 STOP RUN
               WHEN OTHER
                DISPLAY " INVALID CHOICE "
          END-EVALUATE.

          ADD-PARA.
             PERFORM UNTIL MORE-RECORDS ='N' OR 'n'
               DISPLAY DASH-LINE
               DISPLAY "ENTER SEMESTER NO:-" WITH NO ADVANCING
               ACCEPT WS-SEM-NO
               DISPLAY "ENTER STUDENT NO :-" WITH NO ADVANCING
               ACCEPT WS-STU-NO
               DISPLAY "ENTER STUDENT NAME:-" WITH NO ADVANCING
               ACCEPT WS-STU-NAME
               DISPLAY "ENTER GENDER (M/F) :-" WITH NO ADVANCING
               ACCEPT WS-GENDER

               WRITE STU-MST-REC FROM WS-STU-REC
          DISPLAY "WANTS TO ENTER RECORDS (Y/N)? :-"WITH NO ADVANCING
               ACCEPT MORE-RECORDS
               END-PERFORM.


         VEIW-PARA.
               DISPLAY " ENTER SEMESTER NO :-"WITH NO ADVANCING.
               ACCEPT WS-SEM-NO.
               DISPLAY "ENTER STUDENT NO :-"WITH NO ADVANCING.
               ACCEPT WS-STU-NO.

               MOVE WS-SEM-NO TO SEM-NO.
               MOVE WS-STU-NO TO STU-NO.
                    READ STU-FILE
                         INVALID KEY
                              DISPLAY "ERROR READING RECORD"
                         NOT INVALID KEY
                              DISPLAY STU-MST-REC
                    END-READ.

         DELETE-PARA.

               DISPLAY " ENTER SEMESTER NO :-" WITH NO ADVANCING.
               ACCEPT SEM-NO.
               DISPLAY " ENTER STUDENT NO  :-" WITH NO ADVANCING.
               ACCEPT STU-NO.
        VEIW-ALL.
                   OPEN INPUT STU-FILE
                   PERFORM UNTIL EOF="N"
                   READ STU-FILE 
                      AT END MOVE "Y" TO EOF
                      NOT AT END PERFORM V1
                   END-READ
                   END-PERFORM.
          V1.
        DISPLAY STU-MST-REC.
               DELETE STU-FILE 
               INVALID KEY DISPLAY "RECORD NOT FOUND !"
               END-DELETE.

INPUT FILE :-
**********************
112123456789012345678901
101AMISH THHCKER       F
102BHAVIKA             F
117HARSHAD GEDIYA      M
111SHASHANK DESAI      M
155HEMAL SHETH         M
129RAJIV MODH          M



OUTPUT :-
*********************
      STUDENT INFORMATION 

1 ) ADD NEW STUDENT
2 ) VEW STUDENT RECORD 
3 ) DELETE STUDENT RECORD
4 ) VEIW ALL RECORDS 
5 ) EXIT 

ENTER CHOICE1 : 1
ENTER SEMISTER NO : 1
ENTER STUDENT NO : 50
ENTER NAME :KHILAN SHAH
ENTER GENDER :M
WNATS TO ENTER RECORDS (Y/N) :N

      STUDENT INFORMATION 

1 ) ADD NEW STUDENT
2 ) VEW STUDENT RECORD 
3 ) DELETE STUDENT RECORD
4 ) VEIW ALL RECORDS 
5 ) EXIT 

ENTER CHOICE1 :2
ENETR SEMISTER NO :1
ENTER STUDENT NO :1
 SEMNO   STU-NO  NAME          GENDER
 1       1      AMISH THHCKER    F

      STUDENT INFORMATION 

1 ) ADD NEW STUDENT
2 ) VEW STUDENT RECORD 
3 ) DELETE STUDENT RECORD
4 ) VEIW ALL RECORDS 
5 ) EXIT 

ENETR CHOICE1:5
  
Share: 


Didn't find what you were looking for? Find more on STUDENT DETAILS MANAGEMENT USING INDEXED FILE Or get search suggestion and latest updates.

Adalrik Fischer
Adalrik Fischer author of STUDENT DETAILS MANAGEMENT USING INDEXED FILE is from Frankfurt, Germany.
 
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!