PBDR.COM

About   -   Contact   -   Purchase   -   Search   -   What's New

 
 
PB Handling SetAbort Exceptions
Components Developed with PowerBuilder and deployed to Jaguar have a default behavior of raising an exception when a call is made to transaction server primitive SetAbort() function. The way to catch these exceptions in PowerBuilder is to put code in the error event of your connection object and look for the SetAbort error code and then set the return state to ignore the exception.

This is fine for simple components but if you want to return specific error details from your component the calling routine does not receive the contents of any reference parameters. Take the following example:

int AddCustomer( string as_Name, ref long al_NewCustID, ref s_server error astr_Error )
// Add a customer and put the new customer id in the reference field
integer li_Ret

// some code here that populates li_Ret

IF li_Ret < 1 THEN
	astr_Error.s_Msg = 'Cannot create customer for some reason'
	its_Jag.SetAbort()
	RETURN -1
ELSE
	its_Jag.SetComplete()
	RETURN 1
END IF

The server side code here is correct with the call to SetAbort, the problem is the calling PB Client does not get the error details populated into the reference parameter astr_Error structure. Fortunately EAServer has a trick up its sleeve we can use to help out this situation. There is a component property which can be set and tells Jaguar not to raise an exception when a call is made to SetAbort:

com.sybase.jaguar.component.tx_outcome
Setting Description
always (default) The default setting will raise and exception and you will loose your reference parameters.
failed Adding this setting will stop Jaguar sending an exception to the client and means you get to see what's in your reference parameters.

The PowerBuilder deployment painter does not support the setting of this parameter (not that I can find anyway!) so you will need to add this property to your components the first time you deploy them. Don't forget to check the setting when your component goes live!

 

Top of Page

Legal Notice

Ken Howe 2011