Usina BRAdvPL Guide
Sign in
← All topics
COMMANDUnder review

BEGIN SEQUENCE ... END

BEGIN SEQUENCE [BREAK [xValor]] [RECOVER [USING xRecebido]] END SEQUENCE

Routes controlled Break flow to Recover.

BEGIN SEQUENCE ... ENDAdvPL
01 · OVERVIEW

Overview

BEGIN SEQUENCE delimits code whose control can be transferred by Break. RECOVER USING receives the optional Break value. This does not automatically capture every runtime error: converting errors into Break requires appropriate ErrorBlock handling and restoration of the previous handler. The example only uses an explicit interruption, without changing the handler or simulating rollback. BEGIN SEQUENCE and BEGIN TRANSACTION serve different purposes. (TOTVS, n.d., ref. 1)

02 · SYNTAX

Syntax

BEGIN SEQUENCE
    [BREAK [xValor]]
[RECOVER [USING xRecebido]]
END SEQUENCE

Parameters

xValor
AnyOptional

Optional value delivered to Recover.

Return value

Command without its own return; Recover can receive the Break value.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"
User Function EdSeq()
    Local cReason := ""
    Begin Sequence
        // Intentional interruption, not a runtime error.
        Break("Controlled test")
    Recover Using cReason
        ConOut(cReason)
    End Sequence
Return Nil
Expected result

Break message in Recover; no data written or rolled back. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • If using ErrorBlock, restore it on exit paths as well. Do not substitute TLPP Try/Catch without checking language and support.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. BEGIN SEQUENCE ... END. TDN. Accessed on 2026-10-26.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha