Using ON-BREAK on a Hidden Column
In some reports, you may want to use the features of break processing without printing the ON-BREAK option. For example, you may want to incorporate the ON-BREAK option into a subheading. This format might make your report more readable. It is also useful when you want to leave room on the page for additional columns.
To create such a report, you can hide the break option using the PRINT=NEVER qualifier and print it in a heading procedure that is called by BEFORE.
The following code is based on the ex5b.sqr program, with the key lines shown like this:
Program ex5f.sqr
begin-program
do list_customers
end-program
begin-procedure list_customers
begin-select
state () on-break before=state_heading print=never level=1
city (,1) on-break level=2
name (,18)
phone (,49)
position (+1) ! Advance to the next line
from customers
order by state, city, name
end-select
end-procedure ! list_customers
begin-procedure state_heading
print 'State: ' (+1,1) bold ! Advance a line and print 'State:'
print &state (,8) bold ! Print the state column here
print 'City' (+1,1) bold ! Advance a line and print 'City'
print 'Name' (,18) bold
print 'Phone' (,49) bold
print '-' (+1,1,58) fill
position (+1) ! Advance to the next line
end-procedure ! state_heading
Note: This program has no HEADING section. Instead, a procedure prints column headings for each state rather than at the top of each page. The &state variable can be referenced throughout the program, even though the state column was not printed as part of the break.
Examine the following line in the program from the select paragraph:
state () on-break before=state_heading print=never level=1
This line defines the break processing for state. The BEFORE qualifier specifies that the state_heading procedure is automatically called when the state changes. In this program, the break is set to LEVEL=1.
The PRINT=NEVER qualifier hides the state column and specifies that it is not printed as part of the select paragraph. Instead, it is printed in the state_heading procedure. In this procedure, the state column is referred to as the &state column variable.
The city column is assigned a LEVEL=2 break.
The output for the ex5f.sqr program is:
State: IN
City Name Phone
----------------------------------------------------------
Davenport Harold Alexander Fink 3015553645
Miningville Harry's Landmark Diner 3175550948
State: MI
City Name Phone
----------------------------------------------------------
Bell Harbor Sam Johnson 3135556732
State: NH
City Name Phone
----------------------------------------------------------
Frogline Jerry's Junkyard Specialties 6125552877
State: NJ
City Name Phone
----------------------------------------------------------
Teaneck Clair Butterfield 2015559901
State: NM
City Name Phone
----------------------------------------------------------
Big Falls Joe Smith and Company 8085552124
State: NY
City Name Phone
----------------------------------------------------------
Mamaroneck Harriet Bailey 9145550144
New York John Conway 2125552311
Corks and Bottles, Inc. 2125550021
Kate's Out of Date Dress Shop 2125559000
Queens Eliot Richards 2125554285
State: OH
City Name Phone
----------------------------------------------------------
Cleveland Quentin Fields 2165553341
Everretsville Gregory Stonehaven 2165553109
Zanesville Isaiah J Schwartz and Company 5185559813