Advertisement
jolenic

Formatting for Cobol Report

Oct 25th, 2020
2,676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 5.13 KB | None | 0 0
  1. declaring file hierarchy and display stuff in data division:
  2.        data division.
  3.        FD inFile.
  4.        01 inRec.                
  5.            03 employeeID       pic x(4).
  6.            03 jobCode          pic x.
  7.            03 empLastName      pic x(14).
  8.            03 empFirstName     pic x(14).
  9.            03 empStartDate     pic x(8).
  10.            03 storeNo          pic x(4).
  11.            03 weeklySalary     pic 9(4)V9(2).
  12.            03 salesAmount      pic x(8).
  13.        FD salesReport.
  14.        01 salesRecord.
  15.            03 salesLastName    pic x(14).
  16.            03 salesFirstName   pic x(14).
  17.            03 filler           pic x(4) value all spaces.
  18.            03 salesStoreNo     pic x(4).
  19.            03 filler           pic x(19) value all spaces.
  20.        FD salaryExpenses.
  21.        01 expenseRecord.
  22.            03 salaryCat        pic x(11).
  23.            03 filler           pic x(3).
  24.            03 salaryTotal      pic Z(4).9(2).
  25.            03 filler           pic x(25).
  26.            
  27.            
  28.        working-storage section.
  29.        01 ws-eof               pic 9(4) value 0.
  30.            88 end-of-file              value 1.
  31.        01 ws-record-count      pic 9(4) value 0.
  32.        01 expenseTitle     pic x(46) value
  33.            "Salary expense for the week ending: 2020-10-24".
  34.        01 salesReportHeader.
  35.            03 reportTitle      pic x(55) value
  36.            "Employee recognition for the week ending: 2020-10-24".
  37.            03 dashLine         pic x(44) value all '-'.
  38.            03 headings.
  39.                05 ln           pic x(14) value "Last Name     ".
  40.                05 fn           pic x(14) value "First Name    ".
  41.                05 store        pic x(16) value "    Store #     ".
  42.  
  43.  
  44. --------------------------------------------------------------------------------------------------
  45. in working storage:
  46.        01 expenseTitle     pic x(46) value
  47.            "Salary expense for the week ending: 2020-10-24".
  48.        01 salesReportHeader.
  49.            03 reportTitle      pic x(55) value
  50.            "Employee recognition for the week ending: 2020-10-24".
  51.            03 dashLine         pic x(44) value all '-'.
  52.            03 headings.
  53.                05 ln           pic x(14) value "Last Name     ".
  54.                05 fn           pic x(14) value "First Name    ".
  55.                05 store        pic x(16) value "    Store #     ".
  56.        01 blank-line           pic x value " ".
  57.  
  58. -------------------------------------------------------------------------------------------------
  59.  
  60. in prodecure division:
  61.  
  62. once salesReport file is open:
  63.            open output salesReport.
  64.            write salesRecord from reportTitle.
  65.            write salesRecord from dashLine.
  66.            write salesRecord from headings.
  67.            write salesRecord from dashLine.
  68.            move all spaces to salesRecord. ((or else thing print with dashLine!)
  69.  
  70. to write to salesReport:
  71.        check-sales.
  72.            if jobCode = 'S' AND salesAmount > 100000.00
  73.                move empLastName to salesLastName
  74.                move empFirstName to salesFirstName
  75.                move storeNo to salesStoreNo
  76.                write salesRecord
  77.            end-if.
  78.  
  79. after file has finished reading:
  80.            close inFile.
  81.            close salesReport.
  82.            open output salaryExpenses.
  83.            write expenseRecord from expenseTitle.
  84.            write expenseRecord from blank-line.
  85.            write expenseRecord from "STORE #1:".
  86.            move "Management:" to salaryCat.
  87.            move store1-m-total to salaryTotal.
  88.            write expenseRecord.
  89.            move "Sales     :" to salaryCat.
  90.            move store1-s-total to salaryTotal.
  91.            write expenseRecord.
  92.            move "Admin     :" to salaryCat.
  93.            move store1-a-total to salaryTotal.
  94.            write expenseRecord.
  95.            move "Custodial :" to salaryCat.
  96.            move store1-c-total to salaryTotal.
  97.            write expenseRecord.
  98.            write expenseRecord from blank-line.
  99.            write expenseRecord from "STORE #2:".
  100.            move "Management:" to salaryCat.
  101.            move store2-m-total to salaryTotal.
  102.            write expenseRecord.
  103.            move "Sales     :" to salaryCat.
  104.            move store2-s-total to salaryTotal.
  105.            write expenseRecord.
  106.            move "Admin     :" to salaryCat.
  107.            move store2-a-total to salaryTotal.
  108.            write expenseRecord.
  109.            move "Custodial :" to salaryCat.
  110.            move store2-c-total to salaryTotal.
  111.            write expenseRecord.
  112.            write expenseRecord from blank-line.
  113.            write expenseRecord from "STORE #3:".
  114.            move "Management:" to salaryCat.
  115.            move store3-m-total to salaryTotal.
  116.            write expenseRecord.
  117.            move "Sales     :" to salaryCat.
  118.            move store3-s-total to salaryTotal.
  119.            write expenseRecord.
  120.            move "Admin     :" to salaryCat.
  121.            move store3-a-total to salaryTotal.
  122.            write expenseRecord.
  123.            move "Custodial :" to salaryCat.
  124.            move store3-c-total to salaryTotal.
  125.            write expenseRecord.
  126.            close salaryExpenses.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement