Hi guys,
Is there a way to efficiently handle error : TTSCOMMIT without first calling TTSBEGIN ?

I'm creating a class that processing SO-invoice-payment journal, which using custom table, which in its processing, will need certain update/insert processes for handling log, update statuses, etc.
It happens sometime I'm hit this kind of error which is difficult to trace at which class or at line code this error hit.
I'm trying to debug, but sometime found it and sometime it failed as well.
Question : for this transactions, is there a way or special technique to resolve this kind of issue ?
The way I'm doing is pretty simple, in section that I need to insert or update, I put this TTSBEGIN & TTSCOMMIT, I don't think there is some "un-pair" command for this, but the fact is the error arise. Perhaps some method to avoid this problem or maybe some procedure that make the system "auto-run" TTSBEGIN if he found TTSCOMMIT without it ? I'm not sure, but we live in era of AI, also this kind of error I've known this for quite sometime as well, with others developers as well, seems like common but hard to handle until now, just thinking out loud.
Thanks,