LEVEL_BREAK (LB)
Syntax
![]()
Command
Mandatory parameter Optional parameter Mandatory keyword Optional keyword |
LEVEL_BREAK (<Test variable>,
<Footer>[, <Footline>][, <UseNewRecordOnFooting>][, <Header>[, <Headline>]])
<Function list>
Description
The command LEVEL_BREAK is used to create automatic print headers and footers upon change of a value of a field in a loop.
Diagram
Returned value type
None
Parameters
Parameter | Description |
test variable | The test variable is used to trigger the execution of the print instructions or function. Upon a change of the value in the test variable, the footer, header, and any functions defined are performed. The name of the test variable will also be available in the sytem item SI-LEVELBREAK. |
footer | Specification of the layout or routine (which can also include printing of layouts) that must be called for printing additional footer information when the test variable changes. |
footline | Optional indication of the line number from where the printing of the footer must be started. |
header | Specification of the layout or routine (which can also include printing of layouts) that must be called for printing additional header information when the test variable changes. |
headline | Optional, line number for the start of the headline. |
useNewRecordOnFooting | Optional, Levelbreak normally uses the previous record when setting values in the Footer. When this parameter is set to True the values will be set using the new record. Defaults to False. |
Remarks
The LEVEL_BREAK command can only be used within a loop. This can also be a query loop or 'readfile' loop.
The LEVEL_BREAK command must be followed by one or more function calls from the shown list.
Function | Description |
AVERAGE or AVG or MEAN | Average of the values |
COUNT or CNT | Number of values |
MAXIMUM or MAX | Largest value |
MEAN_SQUARES or MSQ | Average of the squares of the values |
MINIMUM or MIN | Smallest value |
STD_DEVIATION or STD | Standard Deviation |
SUM | Sum of the values |
SUM_SQUARES or SSQ | Sum of the squares of the value |
VARIANCE | Variance of the values |
If the LEVEL_BREAK instruction is placed inside a READFILE loop, the actual key that was fetched through the READFILE (before shifting the pointer) can be printed as footer. However, this is only under the following conditions: The must be filled with a field from the buffer for the READFILE instruction that surrounds the applicable LEVEL_BREAK instruction.
Starting from the LEVEL_BREAK instruction, looking from inside out, there may not be encountered any other READFILE instruction (than the one that is needed by the LEVEL_BREAK or loop). Otherwise, there will be no previous record available. So, the footer that is printed will then contain the previously fetched record (and not the current record).
Example
When the employee number (empno) changes, the average of 'salary' will be placed in 'jobsal'
If jobsal already had a value in it, the sum of salary will be added to this value.
level_break (dept, lay_52, lay_50)
count (empno, empnumber)
average (salary, avgsalary)
// empnumber, avgsalary are fields on lay_52
level_break (jobtype, lay_62, lay_56)
count (empno, jobemps)
average (salary, jobsalary)
// jobemps, lobsalary are fields on lay_62
lay10.empnr := empno
lay10.empsalary := salary
...
// lay_10 prints employee details
print (lay_10, prout)
endread
Visit the following links for more print related commands: