BREAK Function (Report, XMLport)
Exits from a loop or a trigger in a data item trigger of a report or XMLport.
BREAK causes the current trigger to end. When used inside a loop, such as a WHILE-DO or REPEAT-UNTIL construction, BREAK interrupts the loop and causes the current trigger to end.
Compare this with the QUIT Function (DATAPORT, REPORT, XMLPORT).
You can also use the C/AL BREAK Statement to exit an iteration or loop. The difference is that the BREAK statement does not terminate the trigger; it just exits the loop.
This example of code in a trigger on a report object requires that you create the following variable and text constant in the C/AL Globals window.
|Text constant||ENU value|
The variable is now %1.
MyVar := 0; REPEAT MyVar := MyVar + 1; IF MyVar = 5 THEN CurrReport.BREAK; MESSAGE(Text000,MyVar); UNTIL Myvar = 10; MESSAGE('After REPEAT-UNTIL loop'); //This statement is never called.
When you run the previous code, the loop will end when MyVar is 5 and the execution of the current trigger ends. Statements after the loop are not executed.