General X++ Development

How do `ttsBegin`, `ttsCommit`, and `ttsAbort` work in X++?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

How do ttsBegin, ttsCommit, and ttsAbort work in X++?

SSunny Vasty75 reputation · answered Aug 13, 2026

ttsBegin starts a transaction scope and ttsCommit commits it.

X++
ttsBegin;

select firstOnly forUpdate myTable
    where myTable.RecId == _recId;

myTable.Status = MyStatus::Complete;
myTable.update();

ttsCommit;

If an exception escapes the transaction, X++ rolls the transaction back.

You normally do not need to scatter ttsAbort everywhere. The bigger concern is making sure your ttsBegin and ttsCommit levels are balanced and that the transaction is not wider than it needs to be.