Transaction Processing

ralphm

Active Member
When entering a voucher in P0411 we need to update a field not included in the begin/edit/end document functions. The way we are going about it is saving the key of the voucher to variables and once the OK button has been pressed on W0411K the app returns to W0411A. In the Clear screen before add, W0411A, event rules we have a table I/O updating using the saved key and field we want updating (if the saved key is populated). The problem is, it is not working 100% af the time e.g. yesterday it failed once out of 75 vouchers. We are assuning that the record has not finished being written when we try to update it. So we have changed the last end doc to run synch but that might be a red herring as the two forms are running with transaction processing on so that the F0411 and F0911 get updated when the OK button is pressed on W0411K.
Is the commit at that point Asynch?
Can we change that?
Is the only solution, to put a loop in before updating the F0411 and guaranteeing that the record is there to update?
 
ralphm,

The commit at that point is like its configured in the enddoc bsfn call. You have to check if its included in transaction. If you want to remove it from the transaction, uncheck the checkbox in the bsfn call.

In my opinion, the best thing you can try to do here is to include the update inside the enddoc function. If there's no way to do it, and you still have to update f0411 after enddoc processing, just remember to handle any possible failures, because is some error occurs during the bsfn processing and the record is not correctly inserted in F0411, you'll have an infinite loop!
 
Move your code in the clear screen before add event, to a NER.
Then call the NER after the end doc call. You can then have the End doc running in Async.
On the NER call, make sure you have the Transaction processing box ticked, as well as the async box ticked.



Peter Hamilton
Xe/B9, Windows NT, AS400
 
Re: RE: Transaction Processing

Thank you it has worked once. I hope it will work 100%.
 
Hi ralphm,

I use generally the following method in your situation:

1.) Place your update logic to the end of Post Button Clicked of OK button (at least after the last BSFN call).

2.) Remove all Asychronous check-mark from all previous BSFN call in this event.

3.) Update F0411:

Open.F0411
Update.F0411 (place here your update logic)
Close.F0411

IMPORTANT: Mark the Include Transaction checkbox in the Open statement (Press the Advanced button on the Open window). Otherwise your Update will be out of the transaction scope of the Form and wont be able to see the changes, that have been made inside the transaction. This means also, that you won't be able without that the newly created record.

An other consideration: marking the Include transaction wil make your DB changes to the part of the main transaction. If the transaction scope is larger than the form (e.g. it is on the caller form) and there the transaction can be rolled back (e.g. canceled), then your changes will be also rolled back.

Please, check the Transaction Processing section in the Developer Tools handbook!

Regards,

Zolán
 
Back
Top