Roll Back on error

Hi All,

My understanding so far was that in case a error is generated while making any transaction, then system will roll back to initial positionj. For example if we are posting a Sales order, then in case of error, the order is not posted and whatever was done before this error popped -up will be rolled back.

I am writing some code wherein I am inserting some data in one table (Journal table) and then using posting routines, I am posting this data to ledgers. But if there is some error in-between then system doesn’t roll back to initial position , rather it creates (inserts) data in Journal line (this is a intermediate step).

So please suggest me where I am doing wrong, why doesn’t it roll back to initial position.

The roll back goes to the last COMMIT, not on the inital position. If in the middle there’s any COMMIT, then it goes to the initial position. Probably there’s a COMMIT in some triggers you are calling. The other possibility is that you are calling the Post Batch codeunit instead of the Post Line codeunit. The Post Batch codeunit contains some COMMITs.

It is not necessary to insert the journal lines before posting them. Simply insert the data into the fields needed and then call the post line codeunit not the post batch.