Skip to Content
0

stored procedure adding

Dec 15, 2016 at 06:37 PM

69

avatar image

Hello,

Finally with great difficulty I added my first stored procedure to SAPB1. I used MSSQL Management Sudio and by expanding DB\ Stored Procedures I located SBO_SP_TransactionNotification SP. Right Mouse Click then Modify and in pop-up window I could edit Stored Procedure. Under the Text “Add your code here” I paste my query for SP. Everything works fine.

My question is How can I add the second Stored Procedure? Where should I paste my second query? I tried in the same window as my first but always got an error when click on the Parse to verify it.

Regards

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Johan Hakkesteegt Dec 16, 2016 at 07:32 AM
0

Hi Wojciech,

You will have to combine all your different logic into one big query. Something along these lines:

IF @OBJECT = something AND some other check
 BEGIN
  your code here
 END
IF @OBJECT = something AND some other check
 BEGIN
  your code here
 END
IF @OBJECT = something else AND some check
 BEGIN
  your code here
 END
etc.

It is also because of this structure that B1 will always only report the first error it encounters.

Regards,

Johan

Share
10 |10000 characters needed characters left characters exceeded
Pradnya S Dec 16, 2016 at 06:39 AM
0

Hi,

Match your begin -- end pair. SPTN should always end with "END" Only thing you should add your code before the last "END"

Regards

Pradnya

Share
10 |10000 characters needed characters left characters exceeded
Wojciech Domanski Dec 16, 2016 at 12:29 PM
0

Thank you for your help but I have still some problem. Two stored procedures work fin if are paste separately but together works only the one which is on the top. Any advaice please?

--------------------------------------------------------------------------------------------------------------------------
IF @OBJECT_TYPE = '2' AND @TRANSACTION_TYPE = 'U'
BEGIN
IF EXISTS(
SELECT top 1 'True' from ocrd T0 Where (select top 1 T1.U_OpInvAllow from acrd T1 where T0.CardCode = T1.CardCode order by T1.LogInstanc desc) <> T0.U_OpInvAllow and T0.UserSign2 <> '1' and T0.CardCode = @LIST_OF_COLS_VAL_TAB_DEL )
BEGIN
SELECT @ERROR=1,@ERROR_MESSAGE='You dont have permission to change the field...!'
END

IF @OBJECT_TYPE = '4' AND @TRANSACTION_TYPE = 'U'
BEGIN
IF EXISTS(
SELECT top 1 'True' from oitm T0 Where (select top 1 T1.U_IntrCode  from AITM T1 where T0.ITEMCODE = T1.Itemcode order by T1.LogInstanc desc) <> T0.U_IntrCode and T0.UserSign2 <> '1' and T0.ITEMCODE = @LIST_OF_COLS_VAL_TAB_DEL )
BEGIN
SELECT @ERROR=1,@ERROR_MESSAGE='You dont have permission to change the field...!'
END
END
end
--------------------------------------------------------------------------------------------------------------------------
if @error_message <> 'Ok' set @error = 999
-- Select the return values
select @error, @error_message
end


Share
10 |10000 characters needed characters left characters exceeded
Wojciech Domanski Dec 16, 2016 at 12:43 PM
0

I found the error. One of the END's I moved up ne of the END's and is ok now. Thanks for help.

Share
10 |10000 characters needed characters left characters exceeded