web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

BP Warning [BPErrorMethodUnbalancedTtsbeginCommit]:The 'ttsabort' statement does not have a clear and unconditional corresponding 'ttsBegin' statement within the same method and scope.

(0) ShareShare
ReportReport
Posted on by 1,552

Hi,

what's wrong with what i wrote?

try
{
    ttsbegin;
    
    --logic
    
    if(flag)
    {
        -- logic 
        ttscommit;
    }
    else
    {
        ttsabort;
    }
}
catch
{
}

I have the same question (0)
  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at
    RE: BP Warning [BPErrorMethodUnbalancedTtsbeginCommit]:The 'ttsabort' statement does not have a clear and unconditional corresponding 'ttsBegin' statement within the same method and scope.

    Hi JuniorAX,

    Could you, please, explain why you want to use ttsAbort?

    Another option could be to throw an error in case if "flag" variable is not set. It will also abort all transactions

    try
    {
        ttsbegin;
        
        --logic
        
        if(!flag)
        {
            throw error("Not flag");
        }
        
        -- logic for flag
        
        ttscommit;
    }
    catch
    {
    }

  • junior AX Profile Picture
    1,552 on at
    RE: BP Warning [BPErrorMethodUnbalancedTtsbeginCommit]:The 'ttsabort' statement does not have a clear and unconditional corresponding 'ttsBegin' statement within the same method and scope.

    Hi Sergie,

    I used ttasbort because i only want ttscommit to happen if the flag is truee, so if i don't put ttsabort, i guess will get an error because ttscommit is only inside the if condtion.

    I prefer to not throw an error, but is this the only option?

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at
    RE: BP Warning [BPErrorMethodUnbalancedTtsbeginCommit]:The 'ttsabort' statement does not have a clear and unconditional corresponding 'ttsBegin' statement within the same method and scope.

    Hi JuniorAX,

    The best practice is not to use ttsAbort if it's really necessary and use throw instead.

    docs.microsoft.com/.../x-standards-ttsbegin-and-ttscommit

  • Suggested answer
    Joris dG Profile Picture
    17,775 on at
    RE: BP Warning [BPErrorMethodUnbalancedTtsbeginCommit]:The 'ttsabort' statement does not have a clear and unconditional corresponding 'ttsBegin' statement within the same method and scope.

    Other than what was already said that you should avoid ttsabort in most cases, the code you wrote should technically work just fine. I'll ask the team to review this best practice but it will be super low priority to be honest.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,188

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 868 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 593 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans