Thanks for that Don, I had been thing it was something real but stupid :-)

OK, search for the Cobol Report Writer manual. That'll do what your colleague has challenged you to with Cobol. Summing, totally, control-breaks etc, all you do is define that they need to be done and with what fields, and the "Report Writer" does the rest.

First, it is an extremely poor question -- probably should be in the homework or interview questions section of this forum, not in the COBOL section.

Second, your colleague obviously wants you to explore COBOL Report Writer, which would be the ONLY way in COBOL to generate the given output without explicit IF statements (Report Writer has implicit IF statements for control breaks).

Third, COBOL Report Writer is NOT part of COBOL -- IBM lists it as a separate product with its own order number (5798-DYR, 5798-DZX for Report Writer versus 5655-S71 for Enterprise COBOL V4.1). So unless a site orders (and pays for) the Report Writer, that functionality will not be present so at many sites what you want to do is not possible, period.

You could even do the pagination with PERFORM UNTILs. If the test is true, the perform does not get done.

Going back to your own Sort suggestion, it is also not so bad. Do the report in Sort, then simply read/write in the Cobol program. Just a perform-until-end-of-file type of thing.

OK, wouldn't meet the input file requirement. So, to keep to the "spirit" of the Cobol-only and the input file, it might, I don't know, be possible to do the formatting of the report as a Cobol internal sort, then just do the printing.

So, although probably not the expected answer, though maybe it is, it is certainly not a bad answer to an odd question, pandora-box.

Oh, dear, it might also be easier than we are thinking.

How about, use the salary as a subscript? Normalise it first, add one. At end of file, empty table (PERFORM UNTIL for table PERFORM UNTIL for non-zero), turn the subscript back to a salary, do the running total. Pagination as above.