ON-BREAK

Causes the specified action in a tabular report when the value of a field changes (a break occurs). The default action prints the field only when its value changes (PRINT=CHANGE).

Syntax

ON-BREAK [PRINT={ALWAYS|CHANGE|CHANGE/TOP-PAGE|NEVER}]
[SKIPLINES={num_lit|_var|_col}]
[PROCEDURE=procedure_name[(arg1[ ,argi]...)]]
[AFTER=procedure_name[(arg1[ ,argi]...)]]
[BEFORE=procedure_name[(arg1[ ,argi]...)]]
[SAVE=txt_var]
[LEVEL=nn]
[SET=nn]

ON-BREAK has the following qualifiers:

The sequence of events for a query containing ON-BREAK fields is:

  1. Any BEFORE procedures are processed in ascending LEVEL sequence before the first row of the query is retrieved.

  2. When a break occurs in the query, the following happens:

    1. AFTER procedures are processed in descending sequence from the highest level to the level of the current break field.

    2. SAVE variables are set with the new value.

    3. BEFORE procedures are processed in ascending sequence from the current level to the highest level break.

    4. Any breaks with the same or higher level numbers are cleared so they do not break on the next value.

    5. If a PROCEDURE has been declared, the procedure is invoked.

    6. If SKIPLINES was specified, the current line position is advanced.

    7. The value is printed (unless PRINT=NEVER was specified).

  3. After the query finishes (at END-SELECT) any AFTER procedures are processed in descending level sequence.

For example:

begin-select
state  (+1,1,2)  on-break level=1  after=state-tot  skiplines=2
county (,+2,14)  on-break level=2  after=county-tot  skiplines=1
city   (,+2,14)  on-break level=3  after=city-tot
...
end-select

Breaks are processed as follows:

If any BEFORE breaks were indicated, they are processed automatically, after all of the AFTER breaks and in sequence from lower to higher level numbers.

For example:

begin-select
state  (+1,1,2) on-break level=1 before=bef-state after=state-tot
county (,+2,14) on-break level=2 before=bef-cnty after=cnty-tot
city   (,+2,14) on-break level=3 before=bef-city after=city-tot
...
end-select

Now when state breaks, the sequence of procedures executed is as follows:

  1. City-tot

  2. Cnty-tot

  3. State-tot

  4. Bef-state

  5. Bef-cnty

  6. Bef-city

Upon entering the query at BEGIN-SELECT, the three BEFORE procedures are executed in sequence:

  1. Bef-state

  2. Bef-cnty

  3. Bef-city

After the last row is retrieved, at END-SELECT, the three AFTER procedures are executed in sequence:

  1. City-tot

  2. Cnty-tot

  3. State-tot

The SAVE qualifier saves the previous break value in the specified string variable for use in an AFTER procedure. You may want to print the previous break field with a summary line:

print  &state  (+1,1)  on-break  after=state-tot  save=$old-state

The SET qualifier allows you to have sub-reports with leveled breaks. By separating the ON‑BREAKs into sets, the associated leveled breaks in each set will not interfere with each other.

begin-select
state  (+1,1,2)  on-break  set=1  after=state-tot  level=1

SET=1 associates this leveled break with other breaks having the same set number.