有关SBO_SP_TransactionNotification介绍

SAP BUSINESS ONE provides the SBO_SP_TransactionNotification stored procedure mechanism for receiving notification of data-driven events.This stored procedure is fired whenever operations are performed on business objects like document or master records in SAP Business One.This applies not only to objects already exposed through DI API,but to any business object in the application-including User-Defined Objects(UDO).By adding your own Transact-SQL code ,you can pass parameters to your application and retrieve the corresponding objects from SAP Business ONE.

The SBO_SP_TransactionNotification stored procedure is created automatically when you create a new company in SAP Business One. It is missing from some of the SAP Business One demo databases (for example the US demo database), but you can easily add it manually using SQL Enterprise Manager or SQL Query Analyzer. When it is initially created, it looks like this:

CREATE proc SBO_SP_TransactionNotification

@object_type nvarchar(20),, -- SBO Object Type

@transaction_type nchar(1),

-- When a record was [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

select @error = 0

select @error_message = N'Ok'

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

-- ADD YOUR CODE HERE

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

-- Select the return values

select @error, @error_message

end

GO

There are five output parameters:

Parameter

Example

Description

@objecttype

2 (Business Partner)

Since version 2005 it returns a string representing the type of object – used to be a numerical value in previous versions.

A full list of object types exposed through DI API can be found in the DI API documentation under the section Enumerations. The enumeration is called BoObjectTypes.

@transaction_type

U (update)

It may have values of:

  • A (where a record was added)
  • U (where a record was updated)
  • D (where a record was deleted),
  • C (where a document was canceled)
  • L (where a document was closed)

@num_of_cols_in_key

1

Returns the number of columns or fields in the key to the record.

A Business Partner, for example, has a key consisting of a single field (CardCode), so this variable would have a value of "1". A Special Prices object, however, has a key consisting of the CardCode and ItemCode, so for a Special Prices object this variable would have a value of "2".

@list_of_key_cols_tab_del

CardCode

It returns a tab-delimited list of column names (field names) that represent the object key.

For a Business Partner, this would be "CardCode". For a Special Prices object, it would be "CardCode ItemCode".

@list_of_cols_val_tab_del

C40001

This returns a tab-delimited list of values required to retrieve the object from Business One.

For example, a Business Partner record might have a value of "C40001". A Special Prices object would contain 2 fields separated by a tab character. For example: "V10005 ... A00001"

For Example :

以下是在项目时做的对生产收货的上些控制
ALTER proc SBO_SP_TransactionNotification

@object_type nvarchar(20), -- 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
select @error = 0
select @error_message = N'Ok'
--------------------------------------------------------------------------------------------------------------------------------

DECLARE @stop smallint --only use it to accord with sql-expression
--生产发货
IF @object_type = '60'
begin
declare @cnt int
declare @PlanQty decimal
declare @IgnQtySum decimal
declare @IgnQtyCur decimal
DECLARE @CN INT
declare @bas int
declare @min decimal
declare @compqty decimal
declare @quan decimal
declare @u_003 varchar(20)
declare @count int
declare @ite varchar(20)
--deal with the transaction based on transactiontype
IF @transaction_type IN('A','U')
declare cursend cursor for select t1.baseentry,sum(t1.quantity) from oign t0,ign1 t1 where t0.docentry=t1.docentry and t1.baseline is null and t0.docentry = @list_of_cols_val_tab_del group by baseentry
open cursend
fetch next from cursend into @bas,@quan
while @@fetch_status=0
begin

--生产订单对应的组件是否已经都发货(不包括反冲件)
SELECT @CN=count(*) FROM OWOR T0,WOR1 T1 WHERE T0.DOCENTRY=T1.DOCENTRY and t0.type in('P','R')AND T1.ISSUETYPE='M' AND T0.DOCNUM=@BAS
and t1.itemcode not in (select T1.ITEMCODE from oige t0,ige1 t1 where t0.docentry=t1.docentry and t1.baseentry=@bas )
select @IgnQtyCur=sum(quantity)from ign1 where docentry = @list_of_cols_val_tab_del group by baseentry
select @PlanQty = plannedqty from owor where docentry = @bas
select @IgnQtySum = sum(quantity) from ign1 where baseentry = @bas and baseline is null
select @compqty=ISNULL(sum(t1.quantity),0) from ign1 t1

where t1.baseentry=@bas and baseline is null

and docentry !=@list_of_cols_val_tab_del
select @min=ISNULL(min(t0.quantity/t1.baseqty),0)

from
(select t1.itemcode,SUM(t1.quantity) quantity
from oige t0,ige1 t1
where t0.docentry=t1.docentry
and t1.baseentry=@bas
GROUP BY T1.ITEMCODE,T1.BASEENTRY) t0,
(SELECT t1.itemcode,t1.baseqty,t0.plannedqty
FROM OWOR T0,WOR1 T1
WHERE T0.DOCENTRY=T1.DOCENTRY
AND T0.DOCNUM=@bas
--AND T1.ISSUETYPE='M'
) t1
where t0.itemcode=t1.itemcode


IF(@CN>0)
begin
SELECT @error = 1
select @error_message=N'请确认生产订单(' +convert(varchar,@bas) +')的所有物料是否已发货!!!'
SELECT @error,@error_message
close cursend
DEALLOCATE cursend
return
end

else if (@IgnQtySum>@PlanQty)
begin
SELECT @error = 1
SELECT @error_message = N'错误---超过订单计划数量收货(订单号=' +convert(varchar,@bas) + N' 计划数量=' + convert(varchar,@planqty) + N' 已执行数量=' + convert(varchar,@IgnQtySum - @IgnQtyCur ) + N')'
SELECT @error,@error_message
close cursend
DEALLOCATE cursend
return
end
else IF EXISTS(SELECT t1.itemcode,t1.baseqty,t0.plannedqty
FROM OWOR T0,WOR1 T1
WHERE T0.DOCENTRY=T1.DOCENTRY
AND T0.DOCNUM=@bas
AND T1.ISSUETYPE='M')
BEGIN
if(@minbegin
SELECT @error = 1
SELECT @error_message = N'错误---生产收货数量('+convert(varchar,@quan)+')'+'大于生产发货数量('+convert(varchar,@min)+')'+'已收货数量('+convert(varchar,@compqty)+')'
SELECT @error,@error_message
close cursend
DEALLOCATE cursend
return
end
END

fetch next from cursend into @bas,@quan
end
close cursend
DEALLOCATE cursend
end

ELSE IF @transaction_type = 'D' --where a record was deleted
begin
select @stop = 0
end
ELSE IF @transaction_type = 'C' --where a document was canceled
begin
select @stop = 0
end
ELSE IF @transaction_type = 'L' --where a document was closed
begin
select @stop = 0
end
end

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/493515/viewspace-910408/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/493515/viewspace-910408/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
pb sbo编程框架是一种用于开发软件的编程框架。它是基于pb编程语言和sbo开发环境构建的,为开发人员提供了一个简单、高效的开发平台。 首先,pb编程语言是一种强大且易于学习的编程语言。它具有良好的可读性和可维护性,使开发人员可以快速开发出稳定、高效的软件。此外,pb编程语言还支持多种开发范式,如面向过程和面向对象,并且提供了大量的内置函数和类,方便开发人员进行编码和调试。 其次,sbo开发环境是一个集成了多种工具和功能的开发平台。它提供了一个可视化的界面,使开发人员可以轻松创建、编辑和调试软件。sbo开发环境还支持快速原型设计和自动化测试,大大提高了开发效率。 pb sbo编程框架通过将pb编程语言和sbo开发环境有机地结合在一起,为开发人员提供了一种全面的开发解决方案。开发人员可以利用pb编程语言的特性和功能来编写核心业务逻辑,同时利用sbo开发环境的工具和功能来快速创建用户界面、进行调试和测试。这样,开发人员可以在短时间内开发出高质量的软件,同时可以灵活地进行修改和扩展。 总之,pb sbo编程框架是一种强大且易于使用的编程框架,它结合了pb编程语言和sbo开发环境的优势,为开发人员提供了一个高效的开发平台。通过使用pb sbo编程框架,开发人员可以快速开发出稳定、高质量的软件,并且可以灵活地进行修改和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值