Advertisement
Nick-O-Rama

assignment-12

Nov 3rd, 2015
2,563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 4.12 KB | None | 0 0
  1.        identification division.
  2.        program-id. Program1.
  3.  
  4.        environment division.
  5.        input-output section.
  6.        select emp-data assign to "C:\temp\emp-data.txt"
  7.            organization is line sequential.
  8.        select print-file assign to "C:\temp\print-file.txt"
  9.            organization is line sequential.
  10.        configuration section.
  11.  
  12.        data division.
  13.        file section.
  14.        fd emp-data.
  15.        01 emp-in.
  16.            05 dept-in          pic 99.
  17.            05 area-in          pic 99.
  18.        fd print-file.
  19.        01 out-rec.
  20.            05 filler           pic x(9).
  21.            05 dept-title       pic x(11).
  22.            05 dept-num         pic 99.
  23.            05 filler           pic x(11).
  24.            05 area-out occurs 20 times.
  25.                10 area-print   pic zz9.
  26.                10 filler       pic x(7).
  27.        working-storage section.
  28.        01 top-heading.
  29.            05                  pic x(43) value spaces.
  30.            05                  pic x(47) value
  31.                "TOTAL NO OF EMPLOYEES BY AREA WITHIN DEPARTMENT".
  32.            05                  pic x(9) value spaces.
  33.            05 the-date.
  34.                10 the-day      pic xx/.
  35.                10 the-month    pic xx/.
  36.                10 the-year     pic xxxx.
  37.            05                  pic x(19) value spaces.
  38.        01 temp-date.
  39.            05 temp-year        pic xxxx.
  40.            05 temp-month       pic xx.
  41.            05 temp-day        pic xx.
  42.        01 area-heading.
  43.            05                  pic x(33) value spaces.
  44.            05                  pic x(5) value "AREA1".
  45.            05                  pic x(5) value spaces.
  46.            05                  pic x(5) value "AREA2".
  47.            05                  pic x(5) value spaces.
  48.            05                  pic x(5) value "AREA3".
  49.            05                  pic x(5) value spaces.
  50.            05                  pic x(5) value "AREA4".
  51.            05                  pic x(5) value spaces.
  52.            05                  pic x(5) value "AREA5".
  53.            05                  pic x(5) value spaces.
  54.            05                  pic x(5) value "AREA6".
  55.            05                  pic x(5) value spaces.
  56.            05                  pic x(5) value "AREA7".
  57.            05                  pic x(5) value spaces.
  58.            05                  pic x(5) value "AREA8".
  59.            05                  pic x(5) value spaces.
  60.            05                  pic x(5) value "AREA9".
  61.            05                  pic x(5) value spaces.
  62.            05                  pic x(6) value "AREA10".
  63.        01 emp-table.
  64.            05 ws-dept occurs 20 times.
  65.                10 ws-area occurs 10 times.
  66.                    15 emp-count pic 999 value zero.
  67.        01 eof                  pic x value "N".
  68.        01 x                    pic 99 value zero.
  69.        01 y                    pic 99 value zero.
  70.        procedure division.
  71.        100-main.
  72.        open input emp-data output print-file
  73.        perform 150-write-headings
  74.        
  75.        perform until eof = "Y"
  76.            read emp-data
  77.            at end move "Y" to eof
  78.            not at end
  79.                if dept-in > 0 and area-in > 0
  80.                    add 1 to emp-count(dept-in, area-in)
  81.                end-if
  82.        end-perform
  83.        perform 200-write-record
  84.        
  85.        close emp-data print-file
  86.            goback.
  87.        150-write-headings.
  88.        move spaces to out-rec
  89.        
  90.        move function current-date to temp-date
  91.        move temp-day to the-day
  92.        move temp-month to the-month
  93.        move temp-year to the-year
  94.        move top-heading to out-rec
  95.        write out-rec
  96.        move area-heading to out-rec
  97.        write out-rec after advancing 1 line.
  98.        200-write-record.
  99.        move spaces to out-rec
  100.        move "DEPARTMENT-" to dept-title
  101.        perform varying x from 1 by 1 until x > 20
  102.            perform varying y from 1 by 1 until y > 10
  103.                move x to dept-num
  104.                move emp-count(x, y) to area-print(y)
  105.            end-perform
  106.            write out-rec after advancing 2 lines
  107.        end-perform.
  108.        end program Program1.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement