Cobol_Transaction_program.txt
上传用户:sky115lz
上传日期:2022-07-24
资源大小:1k
文件大小:5k
源码类别:

其他

开发平台:

Others

  1. $ SET SOURCEFORMAT"FREE"
  2. IDENTIFICATION DIVISION.
  3. PROGRAM-ID.  Program22.
  4. AUTHOR.  Nazim patel.
  5. ENVIRONMENT DIVISION.
  6. INPUT-OUTPUT SECTION.
  7. FILE-CONTROL.
  8.     SELECT Student-Payment-File ASSIGN TO "STUDPAY.DAT"
  9.         ORGANIZATION IS LINE SEQUENTIAL.
  10.     SELECT Print-File ASSIGN TO "FEES.RPT".
  11.     SELECT Student-Master-File ASSIGN TO "STUDMAST.DAT"
  12.         ORGANIZATION IS INDEXED
  13.         ACCESS MODE IS DYNAMIC
  14.         RECORD KEY IS SM-Student-Number
  15.         ALTERNATE RECORD KEY IS SM-Student-Name
  16.              WITH DUPLICATES
  17.         FILE STATUS IS SM-File-Status.
  18.         
  19. DATA DIVISION.
  20. FILE SECTION.
  21. FD  Student-Payment-File.
  22. 01  SP-Rec.
  23.     88  End-Of-SPF      VALUE HIGH-VALUES.
  24.     02  SP-Student-Number               PIC 9(7).
  25.     02  SP-Payment                      PIC 9(4)V99.
  26. FD  Print-File.
  27. 01  Print-Line                          PIC X(76).
  28. FD  Student-Master-File.
  29. 01  SM-Rec.
  30.     88  End-Of-SMF      VALUE HIGH-VALUES.
  31.     02  SM-Student-Number               PIC 9(7).
  32.     02  SM-Student-Name                 PIC X(30).
  33.     02  FILLER                          PIC X(5).
  34.     02  SM-Fees-Owed                    PIC 9(4).
  35.     02  SM-Amount-Paid                  PIC 9(4)V99.
  36. WORKING-STORAGE SECTION.
  37. 01  Heading1.
  38.     02  FILLER                          PIC X(24)  VALUE SPACES.
  39.     02  FILLER                          PIC X(25)
  40.               VALUE "OUTSTANDING  FEES  REPORT".
  41. 01  Heading2.
  42.     02  FILLER                          PIC X(23) VALUE SPACES.
  43.     02  FILLER                          PIC X(27) VALUE ALL "-".
  44. 01  Heading3.
  45.     02  FILLER                          PIC X(30) VALUE " STUDENT  NAME".
  46.     02  FILLER                          PIC X(14) VALUE "STUDENT NO.".
  47.     02  FILLER                          PIC X(9)  VALUE "FEES".
  48.     02  FILLER                          PIC X(12) VALUE "AMT PAID".
  49.     02  FILLER                          PIC X(11) VALUE "AMT OUTSTND".
  50. 01  Detail-Line.
  51.     02  Prn-Student-Name                PIC X(30).
  52.     02  Prn-Student-Number              PIC BBX(7).
  53.     02  Prn-Fees                        PIC BBBBB$$,$$9.
  54.     02  Prn-Amt-Paid                    PIC BBB$$,$$9.99.
  55.     02  Prn-Amt-Outstnd                 PIC BBB$$,$$9.99.
  56. 01  Final-Total-Line.
  57.     02  FILLER                          PIC X(41) VALUE SPACES.
  58.     02  FILLER                          PIC X(20) VALUE "TOTAL OUTSTANDING = ".
  59.     02  Prn-Total-Outstnd               PIC $$,$$$,$$9.99.
  60. 01  Miscellaneous-Items.
  61.     02  Total-Outstanding               PIC 9(7)V99 VALUE ZEROS.
  62.     02  SM-File-Status                  PIC XX.
  63.     02  Amount-Outstanding              PIC 9(4)V99.
  64.    
  65. PROCEDURE DIVISION.
  66. Update-And-Report.
  67.     OPEN I-O Student-Master-File.
  68.     OPEN INPUT Student-Payment-File.
  69.     OPEN OUTPUT Print-File. 
  70.     READ Student-Payment-File
  71.         AT END SET End-Of-SPF TO TRUE
  72.     END-READ.
  73.     PERFORM Update-Master-File UNTIL End-OF-SPF.
  74.     MOVE SPACES TO Print-Line.
  75.     WRITE Print-Line AFTER ADVANCING PAGE.
  76.     WRITE Print-Line FROM Heading1 AFTER ADVANCING 1 LINE.
  77.     WRITE Print-Line FROM Heading2 AFTER ADVANCING 1 LINE.
  78.     WRITE Print-Line FROM Heading3 AFTER ADVANCING 3 LINES.
  79.     MOVE SPACES TO Print-Line.
  80.     WRITE Print-Line AFTER ADVANCING 1 LINE.
  81.     MOVE LOW-VALUES TO SM-Student-Name.
  82.     START Student-Master-File
  83.         KEY IS GREATER THAN SM-Student-Name
  84.         INVALID KEY DISPLAY "Start Error FS = " SM-File-Status
  85.     END-START.
  86.     READ Student-Master-File NEXT RECORD
  87.         AT END SET End-Of-SMF TO TRUE
  88.     END-READ.
  89.     PERFORM Print-Outstanding-Fees-Rpt UNTIL End-OF-SMF.
  90.     MOVE Total-Outstanding TO Prn-Total-Outstnd.
  91.     WRITE Print-Line FROM Final-Total-Line AFTER ADVANCING 3 LINES.
  92.     CLOSE Student-Master-File, Print-File, Student-Payment-File.
  93.     STOP RUN.
  94. Update-Master-File.
  95.     MOVE SP-Student-Number TO SM-Student-Number.
  96.     READ Student-Master-File
  97.         KEY IS SM-Student-Number
  98.         INVALID KEY DISPLAY "invalid read FS = " SM-File-Status
  99.     END-READ.
  100.     ADD SP-Payment TO SM-Amount-Paid.
  101.     REWRITE SM-Rec
  102.         INVALID KEY DISPLAY "Rewrite error fs = " SM-File-Status
  103.     END-REWRITE.
  104.     READ Student-Payment-File
  105.         AT END SET End-Of-SPF TO TRUE
  106.     END-READ.
  107.  
  108.   
  109. Print-Outstanding-Fees-Rpt.
  110.     IF SM-Amount-Paid LESS THAN SM-Fees-Owed 
  111.         SUBTRACT SM-Amount-Paid FROM SM-Fees-Owed GIVING Amount-Outstanding
  112.         ADD Amount-Outstanding TO Total-Outstanding
  113.         MOVE SM-Student-Name TO Prn-Student-Name
  114.         MOVE SM-Student-Number TO Prn-Student-Number
  115.         MOVE SM-Fees-Owed TO Prn-Fees
  116.         MOVE SM-Amount-Paid TO Prn-Amt-Paid
  117.         MOVE Amount-Outstanding TO Prn-Amt-Outstnd
  118.         WRITE Print-Line FROM Detail-Line
  119.                AFTER ADVANCING 1 LINE
  120.     END-IF.
  121.     READ Student-Master-File NEXT RECORD
  122.          AT END SET End-Of-SMF TO TRUE
  123.     END-READ.