Previous Topic: Sequencing the Report DataNext Topic: Formatting Based on Column Value Control Break


Sorting Requirements

Sorting requirements are specified on the Detail fill‑in. You can sort fields in ascending or descending sequence.

In the following example, sorting is requested on the value in STATE in ascending sequence. Notice the 1 typed in the LVL field under the SORT heading. The A in the field marked A/D next to the LVL field specifies an ascending sort.

=> => => ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ IDEAL   : RPT DETAIL DEFN.      RPT CUSTRPT (001) TEST         SYS: DOC DISP         Field Name, Literal       Sort Break Function Column         Function, or               L A L S I T M M A H W Command Arithmetic Expression      V / V K N O A I V D ID Tab Edit Pattern                                    L D L P D T X N G G TH ‑‑‑‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑‑ ‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑ ====== ========== TOP ========== = = = = = = = = = = == === ============= 000400 CUSTOMER.NAME              _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000500 CUSTOMER.CITY              _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000600 CUSTOMER.STATE             1 A _ _ _ _ _ _ _ _ __ ___ _____________ 000700 CUSTOMER.OPEN$             _ _ _ _ _ _ _ _ _ _ __ ___ Z,ZZZ,ZZ9.99_ ====== ======== BOTTOM ========= = = = = = = = = = = == === =============

The following report sample shows the output from Tennessee and Texas. Although all of the customers in Texas are listed together, they are not sorted any further:

SUNSTRAND BANKS             MEMPHIS     TN      932.00 BAY‑BANK AUTOMOBILES        NASHVILLE   TN      543.21 CHEMICAL MUTUAL             FORT WORTH  TX      931.72 GULF LAND USA               DALLAS      TX    7,100.00 TEXAS LIFE & CASUALTY CO DALLAS TX      543.21 AFTON INDUSTRIES DALLAS TX    1,234.51 PALMOLIVE INNS FORT WORTH TX      758.93 SOUTHLAND STORES HOUSTON TX      342.91 UNION TRANSPORTATION GALVESTON TX        0.00

You can specify additional levels of the sort. In the following example, the primary group details are sorted by STATE, CITY, and then by NAME, all in ascending sequence.

=> => => ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ IDEAL   : RPT DETAIL DEFN.      RPT CUSTRPT (001) TEST          SYS: DOC DISP         Field Name, Literal       Sort   Break Function Column         Function, or               L A L S I T M M A H W Command Arithmetic Expression      V / V K N O A I V D ID Tab Edit Pattern                                    L D L P D T X N G G TH ‑‑‑‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑‑ ‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑ ====== ========== TOP ========== = = = = = = = = = = == === ============= 000400 CUSTOMER.NAME              3 A _ _ _ _ _ _ _ _ __ ___ _____________ 000500 CUSTOMER.CITY              2 A _ _ _ _ _ _ _ _ __ ___ _____________ 000600 CUSTOMER.STATE             1 A _ _ _ _ _ _ _ _ __ ___ _____________ 000700 CUSTOMER.OPEN$             _ _ _ _ _ _ _ _ _ _ __ ___ Z,ZZZ,ZZ9.99_ ====== ======== BOTTOM ========= = = = = = = = = = = == === =============

The sort level indication determines the priority of each sort field. The sequence in which you specify the fields as details has no relevance. Now the report output for Texas prints as:

AFTON INDUSTRIES            DALLAS      TX    1,234.51 GULF LAND USA               DALLAS      TX    7,100.00 TEXAS LIFE & CASUALTY CO    DALLAS      TX      543.21 CHEMICAL MUTUAL             FORT WORTH TX      931.72 PALMOLIVE INNS              FORT WORTH TX      758.93 SOUTHLAND STORES            HOUSTON     TX      342.91 UNION TRANSPORTATION GALVESTON   TX        0.00

Regardless of sort specifications, the primary group and its related secondary groups are maintained together. Each PRODUCE of a secondary group associates that detail with the most recent primary group detail.

You cannot compile reports that use RDF sort facilities online, but you must always run them in batch.

You can specify the sort as A for ascending or D for descending. Another collating sequence, such as that specified by CA‑Sort or any of its clones, can be invoked. (Alternate sort packages must be defined at installation.) An alternate collating sequence (ACS) is invoked by specifying + for ascending and ‑ for descending in the A/D field under the SORT heading of the Detail fill‑in.