Numbering control with GetSxeNum, ConfirmSxe and RollbackSxe
Connects number reservation, confirmation and cancellation.
Overview
GetSxeNum obtains a reservation for alias/field rather than a side-effect-free lookup. The selected index must place the field correctly after branch, and additional group/branch arguments have joint rules. TOTVS discourages direct use in field initializers. ConfirmSxe and RollbackSxe belong to the numbering lifecycle and must follow the actual write outcome. Public GETSXENUM.PRW only obtains and displays a number without completing that lifecycle: useful for recognizing invocation, not a complete workflow. Verify SX8 variants found in examples against the release. (TOTVS, n.d., refs. 1–3; EURAI, n.d., ref. 4)
Commented example
// Fragment: own reservation already obtained and caller write completed.
// lWriteConfirmed must reflect the actual outcome, not a visual choice.
If lWriteConfirmed
ConfirmSxe(.T.)
Else
RollbackSxe()
EndIfIllustrates both outcomes for an existing reservation. Not self-contained: requires reservation context, available API and caller error handling. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- Never confirm a reservation from another flow. Test concurrency, cancellation and write failure; do not promise gap-free numbering universally.
- Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.