Wednesday, 2 March 2016

Transaction Tracking System(TTS) in Dynamics AX

Transaction Tracking System normally referred to as TTS is used for tracking transactions. The idea is to secure the entire transaction to be committed to the database. This is vital for a relational database and even more for an ERP system.

To say, while performing an invoice posting you must ensure that this does not result in corrupt data if the system crashes. TTS secures that all database operations within a TTS loop are committed entirely or not at all committed.

Every time you are performing an insert, update or delete you should use the TTS. In fact you cannot update a record without doing it in a TTS loop. And every ttsbegin should have a ttscommit, if not provided an error will be thrown.

Example (1):

static void DataDic_UpdateRecord(Args _args)
MyFirstTable myFirstTable;
select forupdate firstonly myFirstTable;
myFirstTable.custName = "Customer updated";
if (myFirstTable.validateWrite())
throw error("@SYS93835"); //operation cancelled

Here, the first record in MyFirstTable is fetched and the field custName is changed before updating via the ttscommit.

If you need to update a record you must always fetch the record using the keywordforupdate in the TTS loop. A common mistake made when selecting forupdate is to fetch your data for update before calling ttsbegin. If you do this an error will occur.

No comments:

Post a Comment