Advertisement
Guest User

prop-manager

a guest
Nov 19th, 2012
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 4.49 KB | None | 0 0
  1. IDENTIFICATION DIVISION.
  2.     PROGRAM-ID.
  3.         Prop-Manager.
  4.  
  5. ENVIRONMENT DIVISION.
  6.     CONFIGURATION SECTION.
  7.         SPECIAL-NAMES.
  8.             C01 IS to-top-of-page.
  9.     INPUT-OUTPUT SECTION.
  10.         FILE-CONTROL.
  11.             SELECT propmanager-in-file ASSIGN TO 'prop-records.txt'
  12.                 ORGANIZATION IS LINE SEQUENTIAL.
  13.             SELECT propmanager-out-file ASSIGN TO 'income-report.txt'
  14.                 ORGANIZATION IS LINE SEQUENTIAL.
  15.  
  16. DATA DIVISION.
  17.     FILE SECTION.
  18.         FD propmanager-in-file
  19.             LABEL RECORDS ARE STANDARD.
  20.         01 propmanager-in-record.
  21.             05 blding-number        PIC X(5).
  22.             05 office-number        PIC X(4).
  23.             05 office-size          PIC 9(6).
  24.             05 annual-rent          PIC 9(6).
  25.             05 monthly-charges      PIC 9(6).
  26.             05 occupied-code        PIC X.
  27.             05 agent-number         PIC X(2).
  28.  
  29.         FD propmanager-out-file
  30.             LABEL RECORDS ARE STANDARD.
  31.         01 report-record            PIC X(236).  
  32.  
  33.     WORKING-STORAGE SECTION.
  34.         77 EOF-flag             PIC X.
  35.             88 end-of-file                  VALUE 'Y'.
  36.         77 monthly-rent             PIC 9(10).
  37.         77 line-number              PIC 999.
  38.         77 page-number              PIC 999.
  39.         77 prev-agnt-number         PIC XX.
  40.         77 prev-office-number               PIC X(4).
  41.         77 prev-blding-number           PIC X(5).
  42.  
  43.         01 detail-line.
  44.             05 carriage-control     PIC X.
  45.             05 agnt-num-out         PIC XX.
  46.             05 agnt-total-out       PIC 9(13).
  47.             05 blding-number-out            PIC X(5).
  48.             05 building-total-out       PIC 9(13).
  49.             05 office-number-out            PIC X(4).
  50.             05 ofc-total-out        PIC 9(10).
  51.         01 report-page-title.
  52.             05 FILLER           PIC X(30).
  53.             05 report-title         PIC X(20)
  54.                 VALUE '   INCOME   REPORT  '.
  55.             05 page-number-out      PIC X(3).
  56.         01 heading-line.
  57.             05 carriage-control     PIC X.
  58. *>            five spaces between each heading element
  59.             05 FILLER           PIC X(40)
  60.                 VALUE 'AGENT     TOTAL     BUILDING     TOTAL '.
  61.             05 FILLER           PIC X(40)
  62.                 VALUE '    OFFICE     TOTAL'.
  63.         01 total.
  64.             05 agent-total          PIC S9(13).
  65.             05 building-total       PIC S9(13).
  66.             05 office-total         PIC S9(10).  
  67.             05 final-total          PIC S9(15).
  68.         01 total-line.
  69.             05 final-total-out      PIC 9(15).
  70.  
  71. PROCEDURE DIVISION.  
  72.     A000-main-line-routine.
  73.         OPEN INPUT propmanager-in-file
  74.             OUTPUT propmanager-out-file.
  75.         MOVE ZERO               TO final-total.
  76.         MOVE 'N'                TO EOF-Flag.
  77.         MOVE 50                 TO line-number.
  78.         MOVE ZERO               TO page-number.
  79.         READ propmanager-in-file
  80.             AT END MOVE 'Y' TO EOF-Flag.
  81.         PERFORM B010-PROCESS-AGENT-GROUP
  82.             UNTIL end-of-file.
  83.         MOVE SPACES TO detail-line.
  84.         MOVE final-total TO final-total-out.
  85.         PERFORM X010-LINE-OUT.
  86.         CLOSE propmanager-in-file
  87.             propmanager-out-file.
  88.         STOP RUN.
  89.  
  90.     B010-process-agent-group.
  91.         MOVE ZERO TO agent-total.
  92.         MOVE agent-number TO prev-agnt-number.
  93.         PERFORM C010-process-bldg-group UNTIL
  94.             agent-number IS NOT EQUAL TO prev-agnt-number
  95.             OR end-of-file.
  96.         MOVE SPACES TO detail-line.
  97.         MOVE prev-agnt-number to agnt-num-out.
  98.         PERFORM X010-line-out.
  99.         ADD agent-total TO final-total.
  100.  
  101.     C010-process-bldg-group.
  102.         MOVE ZERO TO building-total.
  103.         MOVE blding-number TO prev-blding-number.
  104.         PERFORM D010-process-office-group UNTIL
  105.             blding-number IS NOT EQUAL TO prev-blding-number
  106.              OR agent-number IS NOT EQUAL TO prev-agnt-number
  107.              OR end-of-file.
  108.         MOVE SPACES TO detail-line.
  109.         MOVE prev-blding-number to blding-number-out.
  110.         MOVE building-total TO building-total-out.
  111.         PERFORM X010-line-out.
  112.         ADD building-total TO agent-total.
  113.    
  114.     D010-process-office-group.
  115.         MOVE ZERO TO office-total.
  116.         MOVE office-number TO prev-office-number.
  117.         PERFORM E010-process-acct-record UNTIL
  118.             office-number IS NOT EQUAL TO prev-office-number
  119.              OR blding-number IS NOT EQUAL TO prev-blding-number
  120.              OR agent-number IS NOT EQUAL TO prev-agnt-number
  121.              OR end-of-file.
  122.         MOVE SPACES TO detail-line.
  123.         MOVE prev-office-number TO office-number-out.
  124.         MOVE office-total TO ofc-total-out.
  125.         PERFORM X010-line-out.
  126.         ADD office-total TO building-total.
  127.  
  128.     E010-process-acct-record.
  129.         COMPUTE office-total ROUNDED =
  130.             ((office-size * annual-rent) / 12) + monthly-charges.
  131.         READ propmanager-in-file
  132.             AT END MOVE 'Y' TO EOF-Flag.
  133.  
  134.     X010-line-out.
  135.         ADD 1 TO line-number.
  136. *>          see if end of file is reached
  137. *>          if so, print a new page heading
  138.         IF line-number IS GREATER THAN 50
  139.             ADD 1 TO page-number
  140.             MOVE page-number TO page-number-out
  141.             WRITE report-record FROM report-page-title
  142.                 AFTER ADVANCING to-top-of-page
  143.             WRITE report-record FROM heading-line
  144.                 AFTER ADVANCING 2 LINES
  145.             MOVE SPACES TO report-record
  146.             WRITE report-record
  147.                 AFTER ADVANCING 1 LINE.
  148.             MOVE 1 TO line-number
  149.         WRITE report-record FROM detail-line
  150.             AFTER ADVANCING 1 LINE.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement