Skip to Content

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

SBO_SP_TransactionNotification

Hi All,

I want to check a value of a specific field with this stored procedure.

If before the field is empty and after it contains a value, the update is permitted either no update.

It is possible with the stored procedure ?

This is my code :

DECLARE @IndicatorAfter varchar(2)

DECLARE @IndicatorBefore varchar(2)

DECLARE @LogInstancTop int

DECLARE @LogInstancTop1 int

IF @transaction_type IN (N'U') AND (@Object_type IN ('30'))

BEGIN

IF EXISTS(select * FROM OJDT LEFT OUTER JOIN AJDT ON OJDT.TransID = AJDT.TransID WHERE AJDT.TransID=@list_of_cols_val_tab_del AND (AJDT.LogInstanc > '1'))

BEGIN

SET @LogInstancTop = (SELECT TOP 1 AJDT.LogInstanc FROM OJDT LEFT OUTER JOIN AJDT ON OJDT.TransID = AJDT.TransID WHERE AJDT.TransID=@list_of_cols_val_tab_del ORDER BY AJDT.LogInstanc DESC)

SET @LogInstancTop1 = @LogInstancTop - 1

IF @LogInstancTop=1

BEGIN

SET @IndicatorAfter = (SELECT OJDT.Indicator FROM OJDT WHERE OJDT.TransID=@list_of_cols_val_tab_del)

SET @IndicatorBefore = NULL

END

ELSE

BEGIN

SET @IndicatorAfter = (SELECT OJDT.Indicator FROM OJDT LEFT OUTER JOIN AJDT ON OJDT.TransID = AJDT.TransID WHERE AJDT.TransID=@list_of_cols_val_tab_del AND AJDT.LogInstanc=@LogInstancTop)

SET @IndicatorBefore = (SELECT OJDT.Indicator FROM OJDT LEFT OUTER JOIN AJDT ON OJDT.TransID = AJDT.TransID WHERE AJDT.TransID=@list_of_cols_val_tab_del AND AJDT.LogInstanc=@LogInstancTop1)

END

IF @IndicatorBefore!=@IndicatorAfter AND @IndicatorBefore is null

BEGIN

SET @LogInstancTop=2

END

ELSE

BEGIN

SET @error = 10

SET @error_message = N'Update not possible'

END

END

END

Thanks for response.

Best Regards.

Michael

replied

Trying with something like that:

Declare @CadenaOLD as nvarchar(20)
-- Nota: La subquery que tiene el MAX es para "obviar" el ultimo registro de ACRD (que es el que se "inserta" virtualmente hasta que se haga el commit)

set @CadenaOLD =(select U_FGICADENA FROM ACRD 
	where CardCode =@list_of_cols_val_tab_del
	and loginstanc = 
   (SELECT max(loginstanc) -1 
   FROM ACRD WHERE CardCode = @list_of_cols_val_tab_del
   )
	)

if (@CadenaOLD = "") THEN
...

I hope help you

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question