Reading a Line Sequential File and displaying the content in a neat format


       IDENTIFICATION DIVISION.
       PROGRAM-ID. READING-LINE-SEQUENTIAL-FILE.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER.
       OBJECT-COMPUTER.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT STU-FILE ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD  STU-FILE
           LABEL RECORDS ARE STANDARD
           VALUE OF FILE-ID IS "STU.DAT"
           DATA RECORD IS STU-REC.
       01  STU-REC.
           02 REGNO   PIC 999.
           02 NAME    PIC X(30).
           02 M1      PIC 999.
           02 M2      PIC 999.
           02 M3      PIC 999.
       WORKING-STORAGE SECTION.
       01  TM         PIC 999.
       01  EDT-REC.
           02 EREGNO  PIC ZZ9.
           02 FILLER  PIC XX VALUE SPACES.
           02 ENAME   PIC X(30).
           02 EM1     PIC ZZ9.
           02 FILLER  PIC XX VALUE SPACES.
           02 EM2     PIC ZZ9.
           02 FILLER  PIC XX VALUE SPACES.
           02 EM3     PIC ZZ9.
           02 FILLER  PIC XX VALUE SPACES.
           02 ETM     PIC ZZ9.
       PROCEDURE DIVISION.
       MAIN-PARA.
           PERFORM OPEN-PARA.
           DISPLAY "----------------------------------------------------
      -    "----".
           DISPLAY "                        MARK LIST".
           DISPLAY "----------------------------------------------------
      -    "----".
           DISPLAY "RNO  NAME                           M1   M2   M3  TO
      -    "TAL".
           DISPLAY "====================================================
      -    "====".
       READ-PARA.
           READ STU-FILE RECORD AT END GO TO CLOSE-PARA.
           COMPUTE TM = M1 + M2 + M3.
           MOVE REGNO TO EREGNO.
           MOVE NAME TO ENAME.
           MOVE M1 TO EM1.
           MOVE M2 TO EM2.
           MOVE M3 TO EM3.
           MOVE TM TO ETM.
           DISPLAY EDT-REC.
           GO TO READ-PARA.
       OPEN-PARA.
           OPEN INPUT STU-FILE.
       CLOSE-PARA.
           DISPLAY "====================================================
      -    "====".
           DISPLAY " ".
           CLOSE STU-FILE.
           STOP RUN.

No comments:

Post a Comment