SBO存储过程一例



CREATE   proc SBO_SP_TransactionNotification

@object_type nvarchar(25),                 -- SBO Object Type
@transaction_type nchar(1),            -- [A]dd, [U]pdate, [D]elete, [C]ancel, C[L]ose
@num_of_cols_in_key int,
@list_of_key_cols_tab_del nvarchar(255),
@list_of_cols_val_tab_del nvarchar(255)

AS

begin

-- Return values
declare @error  int                -- Result (0 for no error)
declare @error_message nvarchar (200)         -- Error string to be displayed
declare @aaa nvarchar(255)
declare @ign1_plannedqty numeric(9)
declare @ign1_issuedqty numeric(9)
select @error = 0
select @error_message = N'Ok'

--------------------------------------------------------------------------------------------------------------------------------

--    ADD    YOUR    CODE    HERE
if @object_type='4'--items
begin
if @transaction_type='A'
begin
select @aaa =itemname from oitm where itemcode=@list_of_cols_val_tab_del
if @aaa='Test'
begin
set @error=1
set @error_message='物料主数据描述不能等于Test!'+@aaa +'--'+ @list_of_key_cols_tab_del +'--'+@list_of_cols_val_tab_del +'--'+cast(@num_of_cols_in_key as nvarchar(20))
end
end
else if @transaction_type='D'
begin
set @error=1
set @error_message='不允许小孩子瞎删除!' + @list_of_key_cols_tab_del +'--'+@list_of_cols_val_tab_del +'--'+cast(@num_of_cols_in_key as nvarchar(20))
end
end

if @object_type='59'--oInventoryGenEntry
begin
if @transaction_type='A'
begin

SELECT top 1 @ign1_plannedqty=((t0.quantity+t4.cmpltqty)*t1.baseqty),@ign1_issuedqty=(T1.IssuedQty+t0.quantity*t1.baseqty) FROM IGN1 T0
inner join WOR1 T1 on t0.baseentry = t1.docentry
inner join oign t2 on t0.docentry = t2.docentry
inner join oitm t3 on t1.itemcode = t3.itemcode
inner join owor t4 on t1.docentry = t4.docentry
where t1.plannedqty > t1.issuedqty and t3.IssueMthd = 'M' and t2.docentry = @list_of_cols_val_tab_del

if @ign1_plannedqty > @ign1_issuedqty
begin
set @error=1
set @error_message='料件还没发呢,稀里糊涂的!!!'+ @list_of_key_cols_tab_del +'--'+@list_of_cols_val_tab_del +'--'+cast(@num_of_cols_in_key as nvarchar(20))
end
end
end
--------------------------------------------------------------------------------------------------------------------------------

-- Select the return values
select @error, @error_message

end


GO

你可能感兴趣的:(存储过程,职场,休闲,Sbo)