Skip to Content
avatar image
Former Member

stored procedure adding

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Dec 16, 2016 at 07:32 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 16, 2016 at 06:39 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 16, 2016 at 12:29 PM

    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
    
    
    
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 16, 2016 at 12:43 PM

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

    Add comment
    10|10000 characters needed characters exceeded