Advertisement
Nick-O-Rama

assignment-5

Sep 19th, 2015
1,078
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 5.40 KB | None | 0 0
  1.        program-id. Program1 as "assignment_5.Program1".
  2.        
  3.        environment division.
  4.        input-output section.
  5.        file-control. select payroll-master assign to "C:\temp\payroll-master.txt" organization is line sequential.
  6.                      select payroll-output assign to "C:\temp\payroll-out.txt" organization is line sequential.
  7.        data division.
  8.        fd payroll-master.
  9.        01 payroll-record.
  10.            05 emp-no                                   pic x(5).
  11.            05 emp-name                                 pic x(20).
  12.            05 territory-no                             pic x(2).
  13.            05 office-no                                pic x(2).
  14.            05 annual-salary                            pic 9(6).
  15.            05 ssn-no                                   pic x(9).
  16.            05                                          pic x(36).
  17.        fd payroll-output.
  18.        01 payroll-out-record.
  19.            05                                          pic x.
  20.            05 emp-no-out                               pic x(5).
  21.            05                                          pic x(4).
  22.            05 emp-name-out                             pic x(20).
  23.            05                                          pic x(5).
  24.            05 territory-no-out                         pic x(2).
  25.            05                                          pic x(8).
  26.            05 office-no-out                            pic x(2).
  27.            05                                          pic x(10).
  28.            05 annual-salary-out                        pic $$$,$99.
  29.            05                                          pic x(5).
  30.            05 ssn-no-out                               pic xxxbxxbxxxx.
  31.        working-storage section.
  32.        01 page-heading.
  33.            05                                          pic x(30) value spaces.
  34.            05 payroll-listing                          pic x(15) value "PAYROLL LISTING".
  35.            05                                          pic x(15) value spaces.
  36.            05 page-title                               pic x(5) value "PAGE ".
  37.            05 page-num                                 pic 99 value zero.
  38.            05                                          pic x(3) value spaces.
  39.            05 c-date.                            
  40.                10 current-day                          pic xx/.                      
  41.                10 current-month                        pic xx/.
  42.                10 current-year                         pic xxxx.
  43.        01 temp-date.
  44.            05 temp-year                                pic xxxx.
  45.            05 temp-month                               pic xx.
  46.            05 temp-day                                 pic xx.
  47.        01 field-titles.
  48.            05 emp-no-title                             pic x(8) value "EMP. NO.".
  49.            05                                          pic x(2) value spaces.
  50.            05 emp-name-title                           pic x(13) value "EMPLOYEE NAME".
  51.            05                                          pic x(9) value spaces.
  52.            05 territory-no-title                       pic x(8) value "TERR NO.".
  53.            05                                          pic x(2) value spaces.
  54.            05 office-no-title                          pic x(10) value "OFFICE NO.".
  55.            05                                          pic x(2) value spaces.
  56.            05 annual-salary-title                      pic x(13) value "ANNUAL SALARY".
  57.            05                                          pic x(2) value spaces.
  58.            05 ssn-title                                pic x(11) value "SOC SEC NO.".
  59.        01 end-flag                                     pic x(3) value "YES".
  60.        01 line-num                                     pic 99 value zero.
  61.        procedure division.
  62.        100-main.
  63.        open input payroll-master
  64.             output payroll-output
  65.             move function current-date to temp-date
  66.             perform 150-print-heading
  67.             perform until end-flag = "NO"
  68.                read payroll-master
  69.                    at end move "NO" to end-flag
  70.                    not at end perform 200-write-record
  71.                end-read
  72.            end-perform
  73.            close payroll-master
  74.                  payroll-output
  75.            goback.
  76.        150-print-heading.
  77.            add 1 to page-num
  78.            move temp-year to current-year
  79.            move temp-month to current-month
  80.            move temp-day to current-day
  81.            move page-heading to payroll-out-record
  82.            write payroll-out-record after advancing page.
  83.            move field-titles to payroll-out-record
  84.            write payroll-out-record after advancing 2 lines.
  85.            move zero to line-num
  86.            move spaces to payroll-out-record
  87.            write payroll-out-record after advancing 1 line.
  88.        200-write-record.
  89.            move spaces to payroll-out-record
  90.            move emp-no to emp-no-out
  91.            move emp-name to emp-name-out
  92.            move territory-no to territory-no-out
  93.            move office-no to office-no-out
  94.            move annual-salary to annual-salary-out
  95.            move ssn-no to ssn-no-out
  96.            write payroll-out-record after advancing 1 line.
  97.            add 1 to line-num
  98.            if line-num > 10
  99.                perform 150-print-heading
  100.            end-if.
  101.                
  102.            
  103.        end program Program1.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement