Group Total Reports
(Level Breaks to the RPGIIers)

These standard types of report have been tiresome to construct using GV so we have worked with some clients to come up with a solution to speed up writing these types of program (Thanks to Andy Varey at Dormer Tools for his feedback in this area).

Anyone writing these types of program using either the RPGII cycle or RPG/400 or COBOL will know that the kind of program where you have a file in a particular sequence (e.g. County within Area) and you need to add up and print totals on change of group (i.e. change of each county and a full total for the area on change of area + a grand total) has 3 major areas on which you must concentrate.
1) The first record read - you need titles and headings but not totals.
2) On change of Group - you need to print totals then zeroize the accumulators, and you may need new titles / headings.
3) At end of file - you need all the group totals + the grand total.

In Genesis V you had to work around these situations using 4GL. So to make the task easier we have created a command that will write the 4GL for you. All the specifier has to do is declare a process for the title and end of file formats, a sub-process to which the Primary file to be processed is attached, pick the fields to appear on the report and then run the command to turn it into a Group Totalling Report program. Using the Auto specifier type REPORT will write the basic spec for you but you will need to delete the 4GL created by this type of Auto specification before you call the command.

The Command GVCRTTOT MYPROG will review the spec of the program MYPROG and first look at the Key of the primary file. It will ignore any fields which have been specified as 'S'elect keys (normally where the required key is passed in as a parameter - eg only print area 27) and assume a Group Total is required for all other junior keys (normally 'R' keys). If the key to the logical file has several keys but you do not require totals on the keys at the Junior end of the keylist, do not specify them as 'R' keys. For those key fields chosen GVCRTTOT will create internally defined work fields as totals at each level and for each numeric (non-date) field picked to appear on the print detail format. (If you have a field which is numeric but not a field to be totalled, then don't include it on the print format until after you have run GVCRTTOT.)

GVCRTTOT will then write all the 4GL code necessary to print the first page, accumulate , print and zeroize the totals and deal with the totals at end of file. Rather than document it, I recommend you try it and talk to technical support if there is anything that you don't understand.

There is in fact a new Auto specification type - TOTPRT which can be run which does the the same as GVCRTTOT (in fact, the autospecifier calls this command) however if you have a complex key to the logical file you choose then the auto specifier will not be able to guess how many fields are 'S'elect type keys unless you quote a 'SUPERKEY' file definition. The Auto specifier - type TOTPRT should be the first avenue you choose to try out this feature.