program-id. Program1 as "assignment_5.Program1". environment division. input-output section. file-control. select payroll-master assign to "C:\temp\payroll-master.txt" organization is line sequential. select payroll-output assign to "C:\temp\payroll-out.txt" organization is line sequential. data division. fd payroll-master. 01 payroll-record. 05 emp-no pic x(5). 05 emp-name pic x(20). 05 territory-no pic x(2). 05 office-no pic x(2). 05 annual-salary pic 9(6). 05 ssn-no pic x(9). 05 pic x(36). fd payroll-output. 01 payroll-out-record. 05 pic x. 05 emp-no-out pic x(5). 05 pic x(4). 05 emp-name-out pic x(20). 05 pic x(5). 05 territory-no-out pic x(2). 05 pic x(8). 05 office-no-out pic x(2). 05 pic x(10). 05 annual-salary-out pic $$$,$99. 05 pic x(5). 05 ssn-no-out pic xxxbxxbxxxx. working-storage section. 01 page-heading. 05 pic x(30) value spaces. 05 payroll-listing pic x(15) value "PAYROLL LISTING". 05 pic x(15) value spaces. 05 page-title pic x(5) value "PAGE ". 05 page-num pic 99 value zero. 05 pic x(3) value spaces. 05 c-date. 10 current-day pic xx/. 10 current-month pic xx/. 10 current-year pic xxxx. 01 temp-date. 05 temp-year pic xxxx. 05 temp-month pic xx. 05 temp-day pic xx. 01 field-titles. 05 emp-no-title pic x(8) value "EMP. NO.". 05 pic x(2) value spaces. 05 emp-name-title pic x(13) value "EMPLOYEE NAME". 05 pic x(9) value spaces. 05 territory-no-title pic x(8) value "TERR NO.". 05 pic x(2) value spaces. 05 office-no-title pic x(10) value "OFFICE NO.". 05 pic x(2) value spaces. 05 annual-salary-title pic x(13) value "ANNUAL SALARY". 05 pic x(2) value spaces. 05 ssn-title pic x(11) value "SOC SEC NO.". 01 end-flag pic x(3) value "YES". 01 line-num pic 99 value zero. procedure division. 100-main. open input payroll-master output payroll-output move function current-date to temp-date perform 150-print-heading perform until end-flag = "NO" read payroll-master at end move "NO" to end-flag not at end perform 200-write-record end-read end-perform close payroll-master payroll-output goback. 150-print-heading. add 1 to page-num move temp-year to current-year move temp-month to current-month move temp-day to current-day move page-heading to payroll-out-record write payroll-out-record after advancing page. move field-titles to payroll-out-record write payroll-out-record after advancing 2 lines. move zero to line-num move spaces to payroll-out-record write payroll-out-record after advancing 1 line. 200-write-record. move spaces to payroll-out-record move emp-no to emp-no-out move emp-name to emp-name-out move territory-no to territory-no-out move office-no to office-no-out move annual-salary to annual-salary-out move ssn-no to ssn-no-out write payroll-out-record after advancing 1 line. add 1 to line-num if line-num > 10 perform 150-print-heading end-if. end program Program1.