Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Stored Procedure Script

Hi experts,

Just want to ask a big favor, iam new to stored procedure, please  check my script if its correct: all i want is all if ocrcode code is null or ocrcode5 is null and also invtype = 13  then message  'Please Choose Branch and Department' will show.

please check my script below - thank you very much in advance...

if (@object_type = '24  ') and (@transaction_type= 'A' or @transaction_type= 'U')

BEGIN

If Exists (Select T0.DocNum from ORCT T0 Inner Join RCT2 T1 On T0.DocNum=T1.DocNum

Where T1.OcrCode Is Null And T0.DocNum = @list_of_cols_val_tab_del And T1.InvType = '13' or T1.OcrCode5 Is Null And T0.TransId = @list_of_cols_val_tab_del And T1.InvType = '13' )

BEGIN

Select @error = -1,

@error_message = 'Please Choose Branch and Department'

End

End

Former Member replied

Hi,

As per your requirement you should use OR operator between OcrCode and OcrCode5.Kindly use the below one

IF (@OBJECT_TYPE ='24' AND (@TRANSACTION_TYPE IN('A','U')))

BEGIN

IF EXISTS(

Select T0.DocNum from ORCT T0 Inner Join RCT2 T1 On T0.DocNum=T1.DocNum

Where (isnull(T1.OcrCode,'')='' or isnull(T1.OcrCode5,'')='') And T0.DocEntry = @list_of_cols_val_tab_del

And T1.InvType = '13'

)

BEGIN

SELECT @error=100001, @error_message='Please Choose Branch and Department'

END

END

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question