Advertisement
Nick-O-Rama

assignment-10

Oct 14th, 2015
1,621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 4.48 KB | None | 0 0
  1.        identification division.
  2.        program-id. Program1.
  3.  
  4.        environment division.
  5.        input-output section.
  6.        select sales-trans assign to "C:\temp\sales-trans.txt"
  7.            organization is line sequential.
  8.        select sales-report assign to "C:\temp\sales-report.txt"
  9.            organization is line sequential.
  10.        configuration section.
  11.  
  12.        data division.
  13.        file section.
  14.        fd sales-trans.
  15.        01 sales-file.
  16.            05 salesperson-no       pic 99.
  17.            05 salesperson-name     pic x(20).
  18.            05 amt-of-sales         pic 999v99.
  19.        fd sales-report.
  20.        01 sales-record.
  21.            05                      pic x(17).
  22.            05 salesperson-no-out   pic 99.
  23.            05                      pic x(12).
  24.            05 salesperson-name-out pic x(20).
  25.            05                      pic x(5).
  26.            05 salesperson-sales    pic $zz,zzz.99.
  27.            05                      pic x(16).
  28.        working-storage section.
  29.        01 top-heading.
  30.            05                      pic x(33) value spaces.
  31.            05                      pic x(32) value
  32.                "TOTAL SALES FOR EACH SALESPERSON".
  33.            05                      pic x(4) value spaces.
  34.            05 the-date.
  35.                10 c-day                pic xx/.
  36.                10 c-month              pic xx/.
  37.                10 c-year               pic xxxx.
  38.            05                          pic x(3) value spaces.
  39.        01 record-heading.
  40.            05                      pic x(12) value spaces.
  41.            05                      pic x(15) value "SALESPERSON NO.".
  42.            05                      pic x(4) value spaces.
  43.            05                      pic x(16) value "SALESPERSON NAME".
  44.            05                      pic x(9) value spaces.
  45.            05                      pic x(11) value "TOTAL SALES".
  46.            05                      pic x(15) value spaces.
  47.        01 total-sales-heading.
  48.            05                      pic x(42) value spaces.
  49.            05                      pic x(19) value
  50.                "TOTAL COMPANY SALES".  
  51.            05                      pic x(3) value spaces.
  52.            05 total-sales-out      pic $$,$$$,$$$.99.
  53.            05                      pic x value spaces.
  54.            05                      pic x value "*".
  55.            05                      pic x(3) value spaces.
  56.        01 temp-date.
  57.            05 temp-year            pic x(4).
  58.            05 temp-month           pic x(2).
  59.            05 temp-day             pic x(2).
  60.        01 total-sales              pic 9(9).
  61.        01 i                        pic 99 value 0.
  62.        01 slsprs.
  63.            05 s-name occurs 20 times pic x(20).
  64.            05 s-sales occurs 20 times pic 99999v99.
  65.        01 eof                      pic x value "Y".
  66.        procedure division.
  67.        100-main.
  68.            open input sales-trans output sales-report
  69.            perform 150-write-headings
  70.            perform until eof = "N"
  71.                read sales-trans
  72.                at end move "N" to eof
  73.                not at end
  74.                    perform 300-fill-array
  75.                end-perform
  76.                perform 250-write-record
  77.                perform 350-write-footer
  78.            
  79.            close sales-trans sales-report
  80.            goback.
  81.        150-write-headings.
  82.            perform 200-get-date
  83.            move top-heading to sales-record
  84.            write sales-record
  85.            move record-heading to sales-record
  86.            write sales-record after advancing 1 line.
  87.        200-get-date.
  88.            move function current-date to temp-date
  89.            move temp-day to c-day
  90.            move temp-month to c-month
  91.            move temp-year to c-year.
  92.        250-write-record.
  93.            perform varying i from 1 by 1 until i > 20
  94.                move spaces to sales-record
  95.                move i to salesperson-no-out
  96.                move s-name(i) to salesperson-name-out
  97.                move s-sales(i) to salesperson-sales
  98.                add s-sales(i) to total-sales
  99.                write sales-record.
  100.        300-fill-array.
  101.            if salesperson-no <= 20
  102.                move salesperson-name to s-name(salesperson-no)
  103.                add amt-of-sales to s-sales(salesperson-no)
  104.            end-if.
  105.        350-write-footer.
  106.            move total-sales to total-sales-out
  107.            move total-sales-heading to sales-record
  108.            write sales-record after advancing 2 lines.
  109.        end program Program1.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement