Hi,
In PB .NET (Version 12.6 Build 4011), we are facing a problem in stored procedure call declared using RPCFUNC. The problem in probably occurring if the SP is having output parameters and return value.
Please note that the issue was found only in PB .NET. PB Classic is working fine. I also noticed similar issue in PB 12.5.2.
I am trying to explain the situation with help of following steps:
(1) STORED PROCEDURE in DATABASE (Sybase 15)
Create Proc mpa_aud ( @i_id char(10), @o_typ char(6) = NULL Output)
As
Begin
DECLARE @err_status smallint,
@msg_cd int,
@msg_parms varchar(254)
SELECT @err_status = 0
IF EXISTS (SELECT 1 FROM tbl_zyx WHERE col1 = 'a' AND col2 = 'b')
BEGIN
...some processing here
END
ELSE
BEGIN /* exception situation */
SELECT @err_status = 5,
@msg_cd = 20400,
@msg_parms = "Type not found."
GOTO EndProc
END
EndProc:
IF @err_status != 0
BEGIN
RAISERROR @msg_cd @msg_parms
END
RETURN @err_status
END
(2) RPCFUNC call declaration in PB 12.6 Build 4011
function long mpa_aud (string i_id, refstring o_typ) RPCFUNCALIASFOR"mpa_aud"
(3) PB code to call the SP declared using RPCFUNC
ll_rtn = SQLCA.mpa_aud(ls_id, ls_typ )
Issue:
Based on the data we have in tables, the SP executes the /* exception situation */part of it. Below are the values we get in PB Classic and PB .NET aftre the SP execution:
PB CLASSIC:
ll_rtn = 5
SQLCA.SQLCode = -1
SQLCA.SQLDBCode = 20400
SQLCA.SQLErrTest = "Type not found."
PB .NET:
ll_rtn = 0
SQLCA.SQLCode = -1
SQLCA.SQLDBCode = 20400
SQLCA.SQLErrTest = "Type not found."
ll_rtn = 0 in PB .NET is the issue. It should have been 5, as was in Classic. The ll_rtn value is important as we use this in PB code to decide what kind of further processing should happen.
Workaround: One workaround that came to my mind, and I have tested it and it worked, is to include more output parameter to capture @err_status and change PB code to use the new output parameter to carry on the processing as desired. This could have been used for 1 or 2 instances of the issue.
In reallity, we have 35 applications and I expect this type of SP call more than hundred times. It is not possible to change more than 100 SPs, their RPCFUNC declaration etc etc. I am almost coming to a HALT now in my migration process.
Did anyone face this issue? How did you fix this?
Is it a bug in PB .NET? If so, how to get a fix rom SAP?
Any help is appreciated.
Thanks,
Mazibar