GENERATE { data-name-1 } { report-name1 } |
input-output section. file-control. select SalesFile assign to "gbsales.dat" organization is line sequential. select PrintFile assign to "salesreportb.lpt". file section. fd SalesFile. 01 SalesRecord. 02 CityCode pic 9. 02 SalesPersonNum pic 9. 02 ValueOfSale pic 9(4)V99. fd PrintFile report is SalesReport. working-storage section. 01 eof pic x value low-value. 88 EndOfFile value high-values. 01 NameTable. 02 TableValues. 03 filler pic x(18) value "Dublin Belfast ". 03 filler pic x(18) value "Cork Galway ". 03 filler pic x(18) value "Sligo Waterford". 03 filler pic x(9) value "Limerick". 02 filler redefines TableValues. 03 CityName pic x(9) occurs 7 times. report section. rd SalesReport controls are final CityCode SalesPersonNum page limit is 66 heading 1 first detail 6 last detail 42 footing 52. 01 type is report heading line number is 1. 02 . 03 column 12 pic x(32) value "Report heading of COBOL Program". |
01 type is page heading line number is 2. 02 . 03 column 12 pic x(32) value "An example COBOL Report Program". 02 line plus 1. 03 column 6 pic x(17) value "Bible Salesperson". 03 column 23 pic x(26) value " - Sales and Salary Report". 02 line plus 1. 03 column 2 pic x(4) value "City". 03 column 12 pic x(11) value "Salesperson". 03 column 28 pic x(4) value "Sale". 02 line plus 1. 03 column 2 pic x(4) value "Name". 03 column 13 pic x(6) value "Number". 03 column 28 pic x(5) value "Value". 01 DetailLine type is detail. 02 line is plus 1. 03 column 1 pic x(9) source CityName(CityCode) group indicate. 03 column 15 pic 9 source SalesPersonNum group indicate. 03 column 25 pic $$,$$$.99 source ValueOfSale. 01 SalesPersonGrp type is control footing SalesPersonNum next group plus 2. 02 line is plus 1. 03 column 15 pic x(21) value "Sales for salesperson". 03 column 37 pic 9 source SalesPersonNum. 03 column 43 pic x value "=". 03 sms column 45 pic $$$$$,$$$.99 sum ValueOfSale . 01 CityGrp type is control footing CityCode next group plus 2. 02 line is plus 2. 03 column 15 PIC X(9) value "Sales for". 03 column 25 PIC X(9) source CityName(CityCode). 03 column 43 PIC X value "=". 03 cs column 45 PIC $$$$$,$$$.99 sum sms . 01 TotalSalesGrp type is control footing final. 02 line is plus 4. 03 column 15 pic x(11) value "Total sales". 03 column 43 pic x value "=". 03 column 45 pic $$$$$,$$$.99 sum cs. |
01 type is page footing. 02 line is 53. 03 column 1 pic x(29) value "Sales, Inc.". 03 column 45 pic x(6) value "Page :". 03 column 52 pic z9 source page-counter. 01 type is report footing line number is 66. 02 . 03 column 12 pic x(32) value "End of the COBOL Report Program". procedure division. Begin. open input SalesFile. open output PrintFile. read SalesFile at end set EndOfFile to true end-read. initiate SalesReport. perform PrintSalaryReport until EndOfFile. terminate SalesReport. close SalesFile. close PrintFile. goback. PrintSalaryReport. generate DetailLine. read SalesFile at end set EndOfFile to true end-read. |