ttsbegin, ttscommit and "~" operator

axapta, x++

Solution

From the documentation:

`ttsBegin`: marks the beginning of a transaction. This ensures data integrity, and guarantees that all updates performed until the transaction ends (by `ttsCommit` or `ttsAbort`) are consistent (all or none).

`ttsCommit`: marks the successful end of a transaction. This ends and commits a transaction. MorphX guarantees that a committed transaction will be performed according to intentions.

Note that

It is usually better to use exception handling instead of `ttsAbort`. The throw statement automatically aborts the current transaction.

This means that you would begin a transaction with `ttsBegin` and end it with `ttsCommit` (if successful) or throw an exception (if the transaction is unsuccessful). It is unclear from the documentation, but transactions mean manipulation of application tables.

You would use them when you want to ensure that your read or update operations on application tables are not made inconsistent by other table operations that happen simultaneously

See examples at the same link.

The `~` operator is bitwise not, that flips each bit in an integer number. For example, (assuming 32 bit integer): `~0` is `FFFFFFFF` (each bit is now 1), `~4` is `FFFFFFFB` (hexadecimal representation).

Problem

I'm learning X++ and i have 2 question: I don't understand what is the utility of `ttsbegin and ttscommit` ! where i must use it and what's the utility? X++ Standards: ttsBegin and ttsCommit AX 2012 What is the utility of this operator "~"?

Original source