The default behaviour for dealing with SSO Java exceptions is that the PROIV Virtual Machine treats them as fatal, and a PROIV automatic rollback is performed. SSO Java exception rollback information appears using the @RFUNCT function.

However, this behaviour can be changed in logic if required. You can specify that PROIV Developer handles the exceptions by using the SSOManager method.

For example:

 // Value is in range.

#N = 32767

SSOTagName.shortField = #N

 

// Value is now out of range.

#N = #N + 1

SSOTagName.shortField = #N

By default at runtime, the above code generates an automatic PROIV rollback condition for the second property setting with the following error:

Number

Error

Description

833

SSO SET PROPERTY <tagname.property> FAILED

An SSO set property call generated an exception. Examine the Automatic Rollback Alert windows for more information.

 

However, you may want to handle this error programmatically, and allow the user of your application to enter a lower value rather than have an automatic rollback. You can use the SSOManager methods to do this.

For example:

 // Let the PROIV Developer handle any Java exceptions in the current PROIV function.

SSOManager.ExceptionsRollBack(FALSE)

 

// Value is in range.

#N = 32767

SSOTagName.shortField = #N

 

 

// Value is now out of range.

#N = #N + 1

SSOTagName.shortField = #N

 

$CLASS = SSOManager.GetExceptionClassName()

IF LEN($CLASS) <> 0 AND $CLASS = ‘java.lang.NumberFormatException’

      //

      $MESSAGE = SSOManager.GetExceptionMessage()

      UMSG (‘shortField format error: ‘ + $MESSAGE, -1)

ENDIF

 

Furthermore, you may want to have a combination of automatic rollback to deal with general exceptions, but also leverage the power of SSOManager to detect and handle user errors.

In this example if an exception is returned from openConnection, then it goes undetected:

 // Let the PROIV Developer handle any Java exceptions in the current PROIV function.

SSOManager.ExceptionsRollBack(FALSE)

 

#N = 32000

 

WHILE #N < 32769

SSOHTTP.openConnection()

 

SSOTagName.shortField = #N

$CLASS = SSOManager.GetExceptionClassName()

IF LEN($CLASS) <> 0 AND $CLASS = 'java.lang.NumberFormatException'

            $MESSAGE = SSOManager.GetExceptionMessage()

            UMSG ('shortField format error: ' + CONV(#N) + 'Message' + $MESSAGE, -1)

ENDIF

#N = #N + 1

ENDWHILE

 

The SSOManager method provides the granularity to check exception handling behaviour for individual SSO method and property calls:

 // Let the PROIV Developer handle any Java exceptions in the current PROIV function.

SSOManager.ExceptionsRollBack(FALSE)

 

#N = 32000

 

WHILE #N < 32769

      // The open connection should never fail.

      SSOManager.NextExceptionRollsback(true)

SSOHTTP.openConnection()

 

SSOTagName.shortField = #N

$CLASS = SSOManager.GetExceptionClassName()

IF LEN($CLASS) <> 0 AND $CLASS = 'java.lang.NumberFormatException'

            $MESSAGE = SSOManager.GetExceptionMessage()

            UMSG ('shortField format error: ' + CONV(#N) + 'Message' + $MESSAGE, -1)

ENDIF

#N = #N + 1

ENDWHILE

In the above example, if the SSOTagName.shortField property assignment generates a Java exception, then you can handle it with PROIV code. If the SSOHTTP.openConnection() generates a Java exception then a rollback occurs, because in this example application, it is not a user error.

Comment on this topic

Topic ID: 500582