TEXT   11

MASTER LIST

Guest on 25th November 2021 02:15:42 AM

  1.       ******************************************************************
  2.       * Author:
  3.       * Date:
  4.       * Purpose:
  5.       * Tectonics: cobc
  6.       ******************************************************************
  7.        IDENTIFICATION DIVISION.
  8.        PROGRAM-ID. STUDENT_MASTERLIST.
  9.        ENVIRONMENT DIVISION.
  10.        INPUT-OUTPUT SECTION.
  11.        FILE-CONTROL.
  12.        SELECT StudentList ASSIGN TO "studentList.dat"
  13.          ORGANIZATION IS LINE SEQUENTIAL
  14.          ACCESS MODE IS SEQUENTIAL.
  15.        DATA DIVISION.
  16.        FILE SECTION.
  17.        FD StudentList.
  18.        01 Students.
  19.          02 StudNum PIC 9(7).
  20.          02 StudName PIC X(30).
  21.          02 Gender PIC X(1).
  22.          02 CCode PIC X(4).
  23.          02 Fees PIC ZZZ,Z99.99.
  24.          02 Paid PIC ZZZ,Z99.99.
  25.  
  26.        WORKING-STORAGE SECTION.
  27.        01 WS-Students.
  28.          02 WS-StudNum PIC 9(7).
  29.          02 WS-StudName PIC X(30).
  30.          02 WS-Gender PIC X(1).
  31.          02 WS-CCode PIC X(4).
  32.          02 WS-Fees PIC ZZZ,Z99.99.
  33.          02 WS-Paid PIC ZZZ,Z99.99.
  34.  
  35.  
  36.        01 ret-Students
  37.          OCCURS 1 TO 100 TIMES
  38.          DEPENDING ON rowCounter INDEXED BY i.
  39.          02 ret-StudNum PIC 9(7).
  40.          02 ret-StudName PIC X(30).
  41.          02 ret-Gender PIC X(1).
  42.          02 ret-CCode PIC X(4).
  43.          02 ret-Fees PIC ZZZ,Z99.99.
  44.          02 ret-Paid PIC ZZZ,Z99.99.
  45.  
  46.  
  47.        01 task1 PIC 9.
  48.        01 filestat PIC 99.
  49.  
  50.        01 WS-EOF PIC X(1).
  51.        01 rowCounter PIC 999 VALUE 0.
  52.        01 testvariable PIC X.
  53.  
  54.        01 searchName PIC X(35).
  55.        01 searchFound PIC 9.
  56.        01 rowExist PIC X.
  57.  
  58.        01 userChoice PIC 9 VALUE 0.
  59.       *01 updateRow PIC X.
  60.  
  61.        01 payY PIC 9.
  62.        01 searchID PIC 9(4).
  63.        01 balik PIC x.
  64.        PROCEDURE DIVISION.
  65.        MAIN-PROCEDURE.
  66.          PERFORM Until balik = 'N'    
  67.           PERFORM Balikbalik
  68.  
  69.          DISPLAY "QUESTION?"
  70.          ACCEPT balik
  71.  
  72.          END-PERFORM
  73.        STOP RUN.
  74.  
  75.         Balikbalik.
  76.          
  77.        PERFORM ShowTable.
  78.  
  79.                DISPLAY "**********************************"
  80.                DISPLAY "*----CHOOSE NUMBER TO PERFORM----*"
  81.                DISPLAY "* [1] ADD DATA                   *"
  82.                DISPLAY "* [2] UPDATE DATA                *"
  83.                DISPLAY "* [3] SEARCH DATA                *"
  84.                DISPLAY "* [4] PAYMENT                    *"
  85.                DISPLAY "* [5] PRINT REPORT               *"
  86.                DISPLAY "**********************************"
  87.  
  88.            DISPLAY "ENTER NUMBER TO PERFORM: " WITH NO ADVANCING
  89.            ACCEPT task1
  90.        
  91.        
  92.            IF task1 = 1 THEN
  93.                 PERFORM AddNewRow
  94.  
  95.            ELSE IF task1 = 2 THEN
  96.                 PERFORM UpdateRow
  97.  
  98.            ELSE IF task1 = 3 THEN
  99.  
  100.  
  101.            ELSE IF task1 = 4 THEN
  102.  
  103.  
  104.            ELSE IF task1 = 5 THEN
  105.  
  106.            ELSE
  107.  
  108.                DISPLAY "INVALID INPUT. PLEASE TRY AGIN."
  109.  
  110.            END-IF.  
  111.        
  112.        
  113.       *__________________________FOR SHOW TABLE________________________________*
  114.        ShowTable.
  115.          DISPLAY "-----*****-----".
  116.          DISPLAY "STUDENT'S MASTERLIST".
  117.  
  118.          OPEN INPUT StudentList
  119.              PERFORM UNTIL WS-EOF='Y'
  120.                READ StudentList INTO WS-Students
  121.                  AT END
  122.                    MOVE "Y" TO WS-EOF
  123.                    DISPLAY "--- " rowCounter " rows ---"
  124.                  NOT AT END
  125.                    ADD 1 TO rowCounter
  126.         DISPLAY StudNum"|"StudName"|"Gender"|"CCode"|"Fees"|"Paid
  127.                END-READ
  128.              END-PERFORM.
  129.                MOVE "N" TO WS-EOF  
  130.          CLOSE StudentList.
  131.         DISPLAY "-----*****-----".
  132.  
  133.       *_______________________FOR ADD NEW RECORD_______________________________*    
  134.         AddNewRow.
  135.            DISPLAY " "
  136.            DISPLAY "********** ADD STUDENT *********** "
  137.  
  138.            DISPLAY "Enter Student Number: " WITH NO ADVANCING
  139.            ACCEPT StudNum
  140.  
  141.            DISPLAY "Enter Student Name: " WITH NO ADVANCING
  142.            ACCEPT StudName
  143.  
  144.            DISPLAY "Enter Gender [M / F]: " WITH NO ADVANCING
  145.            ACCEPT Gender
  146.  
  147.            DISPLAY "Enter Course Code: " WITH NO ADVANCING
  148.            ACCEPT CCode
  149.  
  150.  
  151.            MOVE 50000 to Fees
  152.  
  153.            MOVE 00.00 to Paid
  154.            OPEN EXTEND StudentList
  155.              WRITE Students
  156.              END-WRITE
  157.             DISPLAY "Record Inserted"
  158.            CLOSE StudentList.
  159.  
  160.       *________________________FOR UPDATE RECORD_______________________________*
  161.         UpdateRow.
  162.          DISPLAY "Enter id number of row to update: " WITH NO ADVANCING
  163.          ACCEPT searchID
  164.          MOVE "N" TO WS-EOF
  165.          COMPUTE searchFound = 0
  166.       *to find the row
  167.          OPEN INPUT StudentList
  168.            PERFORM VARYING i FROM 1 by 1 UNTIL i > rowCounter
  169.              READ StudentList INTO WS-Students
  170.                AT END MOVE "Y" TO WS-EOF
  171.                NOT AT END
  172.                  IF WS-StudNum = searchID THEN
  173.                    MOVE WS-StudNum TO ret-StudNum(i)
  174.            DISPLAY "Enter Student Number: " WITH NO ADVANCING
  175.            ACCEPT StudNum
  176.  
  177.            DISPLAY "Enter Student Name: " WITH NO ADVANCING
  178.            ACCEPT StudName
  179.  
  180.            DISPLAY "Enter Gender [M / F]: " WITH NO ADVANCING
  181.            ACCEPT Gender
  182.  
  183.            DISPLAY "Enter Course Code: " WITH NO ADVANCING
  184.            ACCEPT CCode
  185.            
  186.                    ACCEPT ret-StudName(i)
  187.                  ELSE
  188.                    MOVE WS-Students TO ret-Students(i)
  189.                  END-IF
  190.              END-READ
  191.            END-PERFORM
  192.          CLOSE StudentList
  193.          PERFORM VARYING i FROM 1 BY 1 UNTIL i > rowCounter
  194.       *>      DISPLAY ret-inventory(i)
  195.            MOVE ret-Students(i) TO Students
  196.            EVALUATE i
  197.              WHEN 1
  198.              PERFORM NewRecord
  199.              WHEN OTHER
  200.              PERFORM AddRecord
  201.            END-EVALUATE
  202.          END-PERFORM.
  203.        NewRecord.
  204.          OPEN OUTPUT StudentList
  205.            WRITE Students
  206.            END-WRITE
  207.          CLOSE StudentList.
  208.        AddRecord.
  209.          OPEN EXTEND StudentList
  210.            WRITE Students
  211.            END-WRITE
  212.          CLOSE StudentList.
  213.       *___________________________________________________________________*
  214.      
  215.        
  216.         END PROGRAM STUDENT_MASTERLIST.

Raw Paste


Login or Register to edit or fork this paste. It's free.