Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
This is one of the main functions of a COBOL program, along with manipulating data.
To generate a report to sysout or a ps file, you need to do the following things in your program.
1 ? define an output file. Generally lrecl 133 in the file division ?FD? along with the associated SELECT.
In the JCL define the report as RECFM=FBA (REPORT is a reserved word pick something else)
2 ? in the working storage section, you need to define each type of line to be written to the file.
a) ? Headers (usually multiple, these contain Titles, Column names, editing line to make the report reader friendly [i.e. underscores for column names, etc]), detail lines, sub-totals and totals line (if appropriate)
3 ? also in working storage you need to define variables for line-count and page-count.
4 ? As you progress through your COBOL program you probably want edit the headers in the initialization paragraph with date, time, program name, starting page # = 1, etc. and write the headers to the file. Set the page-count = 1 and the line-count = however many lines of headers you wrote. (You?ll want to do a search in the forum for line carriage control characters)
Before you write each detail line, you?ll want to check the line-counter, and if greater than a specified value of # lines you want on a page re-write the headers incrementing the page-count and re-setting the line-count.
After each detail line you write, increment the line-count
Note: it?s also good to write a line out if there is nothing to report on a particular run ?i.e. ?NOTHING TO REPORT TODAY? It looks better than a blank report.
Hope this is what you were looking for. There is no magic bullet for creating reports.