................... 9–2 9.1.2 Specifying Sort Parameters with the ASCENDING and DESCENDING KEY Phrases................................ 9–3 9.1.3 Resequencing Files with the USING and GIVING Phrases ......... 9–3 9.1.4 Manipulating Data Before and After Sorting with the INPUT PROCEDURE and OUTPUT PROCEDURE Phrases . . . ........... 9–3 9.1.5 Maintaining the Input Order of Records Using the WITH DUPLICATESINORDERPhrase ............................ 9–6 9.1.6 Specifying Non-ASCII Collating Sequences with the COLLATING SEQUENCE IS Alphabet-Name Phrase........................ 9–7 9.1.7 Multiple Sorting.......................................... 9–7 9.1.8 SortingVariable-LengthRecords ............................. 9–8 9.1.9 PreventingI/OAborts ..................................... 9–9 9.1.10 SortingTables ........................................... 9–9 9.1.11 SortingattheOperatingSystemLevel ........................ 9–9 9.2 MergingDatawiththeMERGEStatement ........................ 9–10 9.3 Sample Programs Using the SORT and MERGE Statements .......... 9–10 10 Producing Printed Reports 10.1 DesigningaReport .......................................... 10–1 10.2 Components of a Report . . . .................................... 10–1 10.3 AccumulatingandReportingTotals .............................. 10–4 10.4 TheLogicalPageandthePhysicalPage .......................... 10–5 10.5 ProgrammingaConventionalFileReport ......................... 10–6 10.5.1 Defining the Logical Page in a Conventional Report . . . ........... 10–6 10.5.2 Controlling the Spacing in a Conventional Report ................ 10–7 10.5.3 Advancing to the Next Logical Page in a Conventional Report . . . . . . 10–7 10.5.3.1 Programming for the Page-Overflow Condition in a Conventional Report .............................................. 10–7 10.5.3.2 Using a Line Counter................................... 10–8 10.5.4 PrintingtheConventionalReport ............................ 10–9 10.5.5 A Conventional File Report Example .......................... 10–9 10.6 Programming a Linage-File Compaq COBOL Report ................. 10–12 10.6.1 Defining the Logical Page in a Linage-File Report................ 10–13 10.6.2 ControllingtheSpacinginaLinage-FileReport ................. 10–14 10.6.3 UsingtheLINAGE-COUNTER .............................. 10–14 10.6.4 Advancing to the Next Logical Page in a Linage-File Report ........ 10–14 10.6.5 Programming for the End-of-Page and Page-Overflow Condition . . . . . 10–15 10.6.6 PrintingaLinage-FileReport ............................... 10–19 10.6.7 A Linage-File Report Example . . . ............................ 10–20 10.7 ModesforPrintingReports .................................... 10–23 10.7.1 DirectlyAllocatingaPrinter ................................ 10–23 10.7.2 Spooling to a Mass Storage Device............................ 10–24 10.8 ProgrammingaReportWriterReport ............................ 10–24 10.8.1 UsingtheREPORTClauseintheFileSection ............