SOURCE.Report sub-divisions.
SUM.
VALUE.
INITIATE.Example.
GENERATE.
TERMINATE.
SUPPRESS.
USE BEFORE REPORTING.
PAGE-COUNTER.
LINE-COUNTER.
[This chapter] [TOC] [Tutorial]
[This chapter] [TOC] [Tutorial]
[This chapter] [TOC] [Tutorial]
[This chapter] [TOC] [Tutorial]
[This chapter] [TOC] [Tutorial]
specifies which field is to be moved to a given print field. It is not possible to move directly to fields in a report element.
specifies which field are to be included in totals.
is used to specify fixed texts on a report.
[This chapter] [TOC] [Tutorial]
PAGE is used to specify page size, the size of headers and footers, and the space provided for detail lines. RWCS uses LINE NUMBER and NEXT GROUP to place these elements and, where necessary, to change to a new page with automatic printing of headers and footers.Logical subdivision
The report's detail groups (DETAIL) can be merged into some control groups. Each control group can begin with a CONTROL HEADING and end with a CONTROL FOOTING. A data name can be assigned to these groups which triggers a break when the value is changed.
[This chapter] [TOC] [Tutorial]
INITIATE.
GENERATE.
TERMINATE.
SUPPRESS.
USE BEFORE REPORTING.
PAGE-COUNTER.
LINE-COUNTER.
[This chapter] [TOC] [Tutorial]
[This chapter] [TOC] [Tutorial]
a) with a data name
b) with a report name
[This chapter] [TOC] [Tutorial]
[This chapter] [TOC] [Tutorial]
[This chapter] [TOC] [Tutorial]
[This chapter] [TOC] [Tutorial]
[This chapter] [TOC] [Tutorial]
* ------ Introduction to exercise 5. identification division. * ------ program identification. program-id. exer5. author. kik. environment division. * ------ program environment. configuration section. special-names. console is crt decimal-point is comma. input-output section. file-control. select isamfile assign "INDXDATA" organization is indexed access is sequential record key is key in isam-record with duplicates status is file-error. +------------------------------------+ ¦ select rep-file assign "REPORT" ¦ ¦ organization is sequential ¦ ¦ access is sequential ¦ ¦ status is file-error. ¦ +------------------------------------+ data division. * ------ description of files. file section. fd isamfile. 01 isam-record. 03 key. 05 custno pic 9999. 05 tr-code pic 99. 03 movement pic 9(6)v99. 03 balance pic 9(6)v99. +----------------------------+ ¦ fd rep-file ¦ ¦ report is report. ¦ +----------------------------+ * ------ variable declarations working-storage section. 01 file-error pic 99. 01 eof-code pic 9 value 0. 88 eof value 1. +------------------------------------------+ ¦ report section. ¦ ¦ rd report ¦ ¦ control is custno in isam-record ¦ ¦ page limit is 66 lines ¦ ¦ first detail 5 ¦ ¦ last detail 60. ¦ +------------------------------------------+ +----------------------------------------------------------+ ¦ 01 page header ¦ ¦ line number is 2 ¦ ¦ type is page heading. ¦ ¦ ¦ ¦ 05 Header pic x(20) value "Header" ¦ ¦ column number is 5. ¦ ¦ NB : FILLER cannot be used here ¦ ¦ 01 customer-header ¦ ¦ line number is plus 2 ¦ ¦ next group is plus 2 ¦ ¦ type is control heading custno in isam-record. ¦ ¦ 05 custno pic 9999 column 1 ¦ ¦ source is custno in isam-record. ¦ ¦ 01 customer-footer ¦ ¦ line number is plus 1 ¦ ¦ next group is plus 1 ¦ ¦ type is control footing custno in isam-record. ¦ ¦ ¦ ¦ 05 foot-string pic x(20) value all "-" ¦ ¦ column 11. ¦ ¦ 05 foot-text pic x(10) column 1 ¦ ¦ line number is plus 1¦ ¦ value "Total". ¦ ¦ 05 cus-move pic -----9v.99 column 11 ¦ ¦ sum movement on detail-line. ¦ ¦ 05 cus-blance pic -----9v.99 column 22 ¦ ¦ sum balance in detail-line ¦ ¦ ¦ ¦ ¦ ¦ 01 detail-line ¦ ¦ line number is plus 1 ¦ ¦ type is detail. ¦ ¦ ¦ ¦ 05 tr-code pic 99 column 7 ¦ ¦ source is tr-code in isam-record. ¦ ¦ 05 movement pic -----9v.99 column 11 ¦ ¦ source is movement in isam-record. ¦ ¦ 05 balance pic -----9v.99 column 22 ¦ ¦ source is balance in isam-record. ¦ +----------------------------------------------------------+ procedure division. * ------ Trap for IO-errors declaratives. * isam-errors section. use after error procedure on isamfile. isam-error. display "Error when accessing isam data : " line 24 position 1. display file-error line 24. stop run. isam-error-out. exit. end declaratives. * * ------ executable instructions. main section. perform open-file. perform read-record. perform process until eof. perform close-file. stop run. * * open-file. open input isamfile. +-----------------------------------+ ¦ open output rep-file. ¦ ¦ initiate report. ¦ +-----------------------------------+ * read-post. read isamfile next at end move 1 to eof-code. * process. +-----------------------------------+ ¦ generate detail-line. ¦ +-----------------------------------+ perform read-post. * close-file. +-----------------------------------+ ¦ terminate report. ¦ ¦ close rep-file. ¦ +-----------------------------------+ close isamfile.
[This chapter] [TOC] [Tutorial]
- COBOL's facilities for handling index-sequential files
- COBOL's facilities for generating reports
- Selections in COBOL
- Calculations
- Numeric editing.
- Print out a report from the index-sequential file created in exercise 1 of chapter 9.
- Provide a total for each value in the field TR-CODE.
- Per customer number
- And for every customer: per transaction code
- A total for all transaction codes.
The text "Customer records per transaction code" is to be written in the middle of the font page, which is to contain nothing else.Header:
The text from the front page plus current date, all of which is to be underlined.Footer:
A page number on every page in the bottom right-hand corner.Customer header:
The records for each customer should be introduced with:Detail line per record:
The text "Customer number:" and the data.
Each record is to be display the following:Customer footer:
Transaction code Movement Balance
A total for each of the above three transaction codes.Report total:
Totals for each of the transaction codes.
[This chapter] [TOC] [Tutorial]
- COBOL's facilities for handling index-sequential files in dynamic mode.