Hi all,
I'm at a bit of a loss with the transactions and exceptions in Axapta. I
have a nested transaction and I would like to be able to roll back the inner
transaction, but not the outer one. I initially tried using ttsabort, but it
seems that ttsabort rolls back the outer transaction as well (ie instead of
dropping from tts level 2 to 1, it drops to 0). The developer guide mentions
that exceptions may be used to abort transactions, so I thought I would do
this. Unfortunately the exceptions exhibit very wierd bahavior.

In my origonal case I have an outer transaction around a while look, and
within that while loop, I am trying to set up an inner transaction. Within
the loop I have a ttsbegin, followed by a try-catch that contains a number
of method calls and a ttscommit. Any of the methods may throw an
error::Exception. The try-catch lists only exception::Error. When I run the
app, the debugger hits the breakpoint on my throw statement, but skips the
catch and it seems that the entire application quits!

I tried testing this in a job, and got similar behavior. The following job
behaves as expected ('error caught' is printed five times and 'finishing
application' is printed once):
int i;
;
    for(i = 0; i < 5; i++)
    {
        //ttsbegin;
        try
        {
            ttsbegin;
            throw exception::Error;
            ttscommit;
        }
        catch(exception::Error)
        {
            print "Error caught";
            pause;
        }
        //ttscommit;
    }

    print "Finishing application";
    pause;

However the following job does not provide any output at all, if a
breakpoint is placed on the throw, it is hit, but stepping over that causes
the job to terminate:
int i;
;
    for(i = 0; i < 5; i++)
    {
        ttsbegin;
        try
        {
            ttsbegin;
            throw exception::Error;
            ttscommit;
        }
        catch(exception::Error)
        {
            print "Error caught";
            pause;
        }
        ttscommit;
    }

    print "Finishing application";
    pause;

What the heck is going on here? What is the correct way to duck out of a
nested transaction?

Regards,

Matt Benic
Axapta Developer
UTi Sun Couriers Division

"The universal aptitude for ineptitude
makes any human accomplishment an incredible miracle."
- Col. John P. Stapp





Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to