Previous Topic: Modify Selection CriteriaNext Topic: Format Print Lines


Define Sorts and Control Breaks

The CONTROL statement defines both the sort criteria and control breaks.

You can sort any field that comes before the sort statement. This includes fields present in the input file and work fields.

The following example sorts the report records by logonid, date, and time hold (the saved military time). The report control breaks on logonid. Parentheses indicate the control break. The CONTROL statement is inserted between the SELECT statement (line 179 of the original report program) and the PRINT statement (line 180).

NOTE ***************************************************************
NOTE DEF WORK FIELD TO SAVE MILITARY TIME
NOTE ***************************************************************

DEF TIMEHOLD(8.0) = 0
        .
        .
        .
NOTE ***************************************************************
NOTE SAVE MILITARY TIME TO THOUSANDTHS OF A SECOND
NOTE ***************************************************************

SET TIMEHOLD=TIME100
        .
        .
        .
 CONTROL (LOGONID) DATE TIMEHOLD

The program modification on the previous page produces the following changes in this report.

03/29/02                           LOGON AND PASSWORD VIOLATIONS
                 STARTING DATE: 03‑29‑02    ENDING DATE: 03‑29‑02
                 STARTING TIME: 10.59       ENDING TIME:  3.04 
‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑
     DATE   TIME         LOGONID    JOBNAME    SUBMITTOR   SOURCE     PROGRAM 
                                               LID/PROC 
‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ 
03‑29‑02   2.48.36  PM  AUEDRL                            H06L83D
                        AUEDRL
03‑29‑02  10.59.30  AM  AUEJJV                            H06L84F
                        AUEJJV
03‑29‑02   1.24.58  PM  SSESWB     SSESWB     LOGON       V4L3E0
                        SSESWB
03‑29‑02   2.02.48  PM  SVNSKS     SVNSKS     LOGON       V4L3EA
                        SVNSKS
03‑29‑02  11.09.55  AM  TLCISO     STARMAN    STARMAN     USCHGOVB
03‑29‑02  11.21.50  AM  TLCISO     TLCISO     LOGON       V4L3ED
03‑29‑02   2.20.10  PM  TSTRJM                            H06L867
                        TSTRJM

Note: When you use sort logic, the DATE and TIME variables in the title no longer contain the start time. Therefore, if you use these fields in the title, the report logic is modified to reflect the first presort record. This technique is demonstrated in the complete modified report at the end of this chapter.