Continuing from my first post on the wish for a Try and Catch control structure within the U2 products, I had decided to see if I could create one within SB+ using a new input screen which eventually automatically creates a SB+ Paragraph process.
The Try part of the structure will consist of a list of SB+ processes which will be executed top down until one returns an error code via RTN.FLAG. RTN.FLAG is a common variable which is used to pass back errors from all SB+ processes. If this flag is zero, then no errors has occurred. The possible values are documented within the SB+ manuals and in the online help. They can also be user created, but normally for error tracking, 0 is OK, 1 is an error.
So, to convert each process in the list to a SB+ Paragraph line would look like:
LOCAL CATCH.ERROR, CATCH.PROCESS * EXEC "processname" * IF @RTN.FLAG # 0 then * CATCH.ERROR = @RTN.FLAG CATCH.PROCESS = processname GOTO 9999 END
The Catch part of the structure would consist of a CASE statement:
9999: BEGIN CASE CASE CATCH.ERROR = "1" AND CATCH.PROCESS = "processname" * EXEC "processname" CASE CATCH.ERROR = "1" * EXEC "processname" CASE CATCH.ERROR = "X" * EXEC "processname" CASE 1 * EXEC "processname" END CASE
So, if the following try and catch statement was:
TRY * GET.USER.PARAMS GET.WEB.INFO PROCESS.TRANS CATCH "X" REVERSE.TRANS * END
then the resultant SB+ paragraph process would be:
EXEC "GET.USER.PARAMS" IF @RTN.FLAG # 0 THEN * CATCH.ERROR = @RTN.FLAG CATCH.PROCESS = "GET.USER.PARAMS" GOTO 9999 END * EXEC "GET.WEB.INFO" IF @RTN.FLAG # 0 THEN * CATCH.ERROR = @RTN.FLAG CATCH.PROCESS = "GET.WEB.INFO" GOTO 9999 END * EXEC "PROCESS.TRANS" IF @RTN.FLAG # 0 THEN * CATCH.ERROR = @RTN.FLAG CATCH.PROCESS = "PROCESS.TRANS" GOTO 9999 END * GOTO 99991 * 9999: BEGIN CASE CASE CATCH.ERROR = "X" CASE 1 END CASE 99991:
Now it is just a matter of creating a SB+ paragraph within the xxPROCESS file and add all the SB+ internals…