ITPUB??ì3
报名申请微软有影响力专家
ITPUB论坛 » SAP R/3 » SAP Business One开发与快速实施 » SBO中的一个极具震撼力的的流程控制功能详细分析

标题: [精华] SBO中的一个极具震撼力的的流程控制功能详细分析
离线 weilingjun
版主


精华贴数 3
个人空间 0
技术积分 511 (3963)
社区积分 0 (1026183)
注册日期 2006-7-9
论坛徽章:2
管理团队成员ITPUB新首页上线纪念徽章    
      

发表于 2007-5-27 15:51 
SBO中的一个极具震撼力的的流程控制功能详细分析

在我开发的项目过程中,许多客户和顾问向我提出了许许多多的功能需求。但我在分析研究了这些需求后发现许多的需求我们顾问均可以解决。尤其是流程控制方面的需求。我把这方面的一些粗浅看法整理出来,供大家分享。
一、各种顾问在项目实施过程中出现过的看是需要研发解决的需求
  1、如何控制不同的销售人员只能修改自己管理的客户的数据?
  2、如何控制不同的销售人员只能录入修改自己的销售订单?
  3、如何给sbo的任何单据(我这里强调任何单据,包括销售订单,销售发货单、发票、采购订单、采购收货单、采购发票、财务凭证、库存转储等等)加上自己的逻辑验证控制(例如不填某一个字段不用许sbo添加到数据库)
  4、如何在各种单据或主数据添加修改过程中加上自己想要的功能?
   
  以前这些需求一般都是顾问要求研发人员来参与协同工作来解决。我们现在要讨论的就是这些问题统统不再研发,顾问可轻松搞定。当然这要求顾问要具备一些基础知识。
二、顾问要解决这些问题要具备的基础知识
1、sql的知识。我一直认为,一个ERP软件顾问高手对SQL必须的基本素质。他可以让你随心所欲从这个充满金矿的ERP数据海洋里找到你想要的金子。我认为有志于成为ERP软件顾问高手的朋友在此付出一点时间和金钱是绝对值得的!它是打开我们理解ERP软件内核的金钥匙,也是会让我们终生受益的一种技能。无论我们从事的是哪一个ERP系统的顾问工作!
2、SBO对象的概念与规则。
  当然,我觉得您在读这篇杂论前要有坚持读下去的意志。尽管这好像是有点枯燥乏味。但这点乏味的知识会给您带来无穷的想象力!
  SBO的DI对象,针对顾问通俗点简单点说就像物料主数据、客户主数据、销售订单、采购订单等等这些SBO里的东东。他们在SBO系统里都有一个编号,就像我们都有一个名字一样用于唯一识别。例如物料主数据的编号是:4。具体清单如下:
Member        Value
oChartOfAccounts        1
oBusinessPartners        2
oBanks        3
oItems        4
oVatGroups        5
oPriceLists        6
oSpecialPrices        7
oItemProperties        8
oUsers        12
oInvoices        13
oCreditNotes        14
oDeliveryNotes        15
oReturns        16
oOrders        17
oPurchaseInvoices        18
oPurchaseCreditNotes        19
oPurchaseDeliveryNotes        20
oPurchaseReturns        21
oPurchaseOrders        22
oQuotations        23
oIncomingPayments        24
oJournalVouchers        28
oJournalEntries        30
oStockTakings        31
oContacts        33
oCreditCards        36
oCurrencyCodes        37
oPaymentTermsTypes        40
oBankPages        42
oManufacturers        43
oVendorPayments        46
oLandedCostsCodes        48
oShippingTypes        49
oLengthMeasures        50
oWeightMeasures        51
oItemGroups        52
oSalesPersons        53
oCustomsGroups        56
oChecksforPayment        57
oInventoryGenEntry        59
oInventoryGenExit        60
oWarehouses        64
oCommissionGroups        65
oProductTrees        66
oStockTransfer        67
oWorkOrders        68
oCreditPaymentMethods        70
oCreditCardPayments        71
oAlternateCatNum        73
oBudget        77
oBudgetDistribution        78
oMessages        81
oBudgetScenarios        91
oSalesOpportunities        97
oUserDefaultGroups        93
oSalesStages        101
oActivityTypes        103
oActivityLocations        104
oDrafts        112
oDeductionTaxHierarchies        116
oDeductionTaxGroups        117
oAdditionalExpenses        125
oSalesTaxAuthorities        126
oSalesTaxAuthoritiesTypes        127
oSalesTaxCodes        128
oQueryCategories        134
oFactoringIndicators        138
oPaymentsDrafts        140
oAccountSegmentations        142
oAccountSegmentationCategories        143
oWarehouseLocations        144
oForms1099        145
oInventoryCycles        146
oWizardPaymentMethods        147
oBPPriorities        150
oDunningLetters        151
oUserFields        152
oUserTables        153
oPickLists        156
oPaymentRunExport        158
oUserQueries        160
oMaterialRevaluation        162
oCorrectionPurchaseInvoice        163
oCorrectionPurchaseInvoiceReversal        164
oCorrectionInvoice        165
oCorrectionInvoiceReversal        166
oContractTemplates        170
oEmployeesInfo        171
oCustomerEquipmentCards        176
oWithholdingTaxCodes        178
oBillOfExchangeTransactions        182
oKnowledgeBaseSolutions        189
oServiceContracts        190
oServiceCalls        191
oUserKeys        193
oQueue        194
oSalesForecast        198
oTerritories        200
oIndustries        201
oProductionOrders        202
oPackagesTypes        205
oUserObjectsMD        206
oTeams        211
oRelationships        212
oUserPermissionTree        214
oActivityStatus        217
oChooseFromList        218
oFormattedSearches        219
oAttachments2        221
oUserLanguages        223
oMultiLanguageTranslations        224
oDynamicSystemStrings        229
oHouseBankAccounts        231
oBusinessPlaces        247
oLocalEra        250
oSalesTaxInvoice        280
oPurchaseTaxInvoice        281
BoRecordset        300
BoBridge        305
oNotaFiscalUsage        260
oNotaFiscalCFOP        258
oNotaFiscalCST        259
oClosingDateProcedure        261
oBusinessPartnerGroups        10
oBPFiscalRegistryID        278

三、关键的存储过程语法:
大家打开sqlserver的查询分析器,打开SBO的一个公司数据库,查找一个存储过程:SBO_SP_TransactionNotification
它就是让我们得以控制SBO的魅力所在!
ALTER  proc SBO_SP_TransactionNotification

@object_type nvarchar(25),                                 -- SBO Object Type
@transaction_type nchar(1),                        -- [A]dd, 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

这个存储过程的作用就是任何一个SBO对象操作完程前都会调用它一次。以便我们加入我们的逻辑控制来实现一些客户的特殊要求。
我们来看一下他的参数:
第一个参数:@object_type 这就是我们上边讨论的SBO对象的编号。每一个对象执行Add, pdate, [D]elete, [C]ancel, C[L]ose操作时都会把操作的对象编号在这个参数中传入,我们只要判断该参数即可实现对不同的对象的不同的控制。我后边会给大家提供一些练习。
第二个参数:@transaction_type nchar(1),                        -- [A]dd, pdate, [D]elete, [C]ancel, C[L]ose
当在SBO系统中执行了添加操作,例如添加了一个物料主数据,@object_type的值就等于4,@transaction_type的值就等于'A' 。
第三个参数:@num_of_cols_in_key,对象关键字段的数目。例如物料主数据的关键字段是物料编码,他只有一个关键字,所以该值等于1。
第四个参数:@list_of_key_cols_tab_del  代表该对象的关键字段的字段名字,例如物料主数据就是Itemcode,单据就是Docentry.
第五个参数:@list_of_key_cols_tab_del  代表关键字段的值。这时已非常重要的参数。我再次说明一点,经过我测试,SBO的对象再添加修改时会现在数据库里操作完成,然后调用该存储过程。所以我们就靠这个字段来作为验证控制我们的逻辑的入口之一了。
   在以上介绍的五个参数之中,最重要的就是@object_type,@transaction_type,@list_of_cols_val_tab_del这三个参数。大家一定要明白他们的含义!

内部的两个重要控制参数:
@error ,好了,揭示了这么多,就数他最重要了。计算机世界的0和1就让他体现的淋漓尽致了。当我么给它赋值为零的时候,SBO的流程继续运行。一旦我们给他赋值为1,好了,效果出现了,你在sbo中操作的对象就再也不能完成它的操作了!牛!就是这个牛的地方可以让我们收拾SBO任何的对象,可以按客户的心花让SBO尽情的怒放。
当然我们经过我们自己的逻辑,把 @error =1,不然SBO按自己的逻辑继续下去了,总也得在SBO中给出个提示把,就像B1的状态栏的提示一样,那您就要动用@error_message这个参数了。200个字符尽情地表述您的一肚子逻辑的解释吧,幽默也好,冷冰冰也罢!

好了我们解释过了这个存储过程的架构,那我接下来看看它的威力。看看SBO的牛皮吹得力量能不能把鸡蛋吹成气球!

四、几个小例子

第一个例子:我们就测试一下物料主数据,并看一下这几个参数。
在查询分析器打开该存储过程,让其处于编辑状态,要仔细找,SBO的存储过程密密麻麻一大堆,看起来确实头疼,对一个顾问来说。但研发人员也许不这样认为。研发人员对代码的好奇心永远是无止境的。我就曾经把SBO的存储过程一个接一个的读了个遍。管他加密的不加密的。读了会有收获的!呵呵。也让咱看看SAP的牛人们使用什么样的代码来操作这个世界的企业用户的数据的!

ALTER  proc SBO_SP_TransactionNotification

@object_type nvarchar(25),                                 -- SBO Object Type
@transaction_type nchar(1),                        -- [A]dd, 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(100)                     --WLJ test

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

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

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

end

在这个例子里,我们首先对添加的物料主数据判断其描述是否等于“Test”如果是,那就不让它添加,对于物料主数据则不允许删除。大家注意分析各参数的内容。我在这个例子里把各个参数的值也传递到SBO的消息提示里边,这样大家学习分析方便!


第二个例子:上边的例子我们测试验证了主数据,我们下边来看一下单据。
ALTER  proc SBO_SP_TransactionNotification

@object_type nvarchar(25),                                 -- SBO Object Type
@transaction_type nchar(1),                        -- [A]dd, 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(100)                     --WLJ test

select @error = 0
select @error_message = N'Ok'

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

--        ADD        YOUR        CODE        HERE

if  @object_type='17'--salseorder
begin
    if @transaction_type='A'
    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
    else if @transaction_type='U'
    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


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

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

end
当然这个例子我写得简单,只是测试在销售订单添加或更新的时候强不允许添加或更新。大家可以根据自己的逻辑来实际处理。我这里只是给大家提供一个思路。

整合,当然我们实际工作中不可能只对一个对象操作,有可能对很对对象同时验证,那就把上边的合起来即可,即可以对物料主数据控制也可以对销售订单控制。我给大家写了个小架构供大家参考使用。
ALTER   proc SBO_SP_TransactionNotification

@object_type nvarchar(25),                                 -- SBO Object Type
@transaction_type nchar(1),                        -- [A]dd, 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 @aaa  nvarchar(100)

if  @object_type='2' --BusinessPartners
begin
    if @transaction_type='A'
    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
else 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='添加出错提示!'+@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
else if  @object_type='17'--salseorder
begin
    if @transaction_type='A'
    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
    else if @transaction_type='U'
    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
--else if  @object_type='17'--salseorder
--begin
--end
--..........
--.........
end


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

end
.
五、结束语。其实这个功能也是我们业界的一个资深顾问给我的提示,因为在我们这个行业中有很多善于研究的顾问高手在这个市场里通过它淋漓尽致的在SBO里使展着无穷无尽的创意!在他们眼力,没有不可能的事,只有不可能的人!每当面对这句话的时候,我对自己以前顾问提出的需求做出不可能的回答而感到汗颜与惭愧!


只看该作者    顶部
离线 weilingjun
版主


精华贴数 3
个人空间 0
技术积分 511 (3963)
社区积分 0 (1026183)
注册日期 2006-7-9
论坛徽章:2
管理团队成员ITPUB新首页上线纪念徽章    
      

发表于 2007-5-27 15:57 
当我在公司做完这个培训后,我们公司的优秀的研发人员HOT及时测试了最新的SBO补丁下该存储过程的表现行为,并同SAP公司的技术人员作了交流与验证。我们对他的对于技术的追求精准致以谢意!
以下是他最新跟踪的情况说明:
各位:
   上星期六,小魏给大家演示了一个非常震撼的存储过程,但此存储过程在PL20,
以及PL22 ,PL23 版本有变动,一些事件已经不再触发此存储过程,被
SBO_SP_PostTransactionNotice 新的存储过程替代。

Question:

Hello,
   After installation of patch 20 of SBO 2005 A SP1 we saw that
SBO_SP_TransactionNotice was not called anymore when inserting a country,
currency,... For an update it is still called but not for an insert.
Because of that our synchronization application is not working anymore if
somebody is adding a currency, country,...
The strange thing is that when inserting a business partner it is working.

Tanks.

Jeffrey


Answer:

Jeffrey,

   Per the note that you reference, SAP did make a change and is now
using the SBO_SP_PostTransactionNotice instead of the
SBO_SP_TransactionNotification stored procedure. You will need to update
the SBO_SP_PostTransactionNotice with the code you used in the
SBO_SP_TransactionNotification stored procedure.

Eddy

                                             HOT


只看该作者    顶部
离线 11223345566778
初级会员



精华贴数 0
个人空间 0
技术积分 98 (17653)
社区积分 0 (1400562)
注册日期 2007-5-16
论坛徽章:0
      
      

发表于 2007-5-28 11:37 
受益良多,顶!


只看该作者    顶部
离线 liuliu009
资深会员



精华贴数 0
个人空间 0
技术积分 1975 (865)
社区积分 9 (11846)
注册日期 2004-4-26
论坛徽章:4
会员2006贡献徽章授权会员生肖徽章2007版:鸡ERP板块每日发贴之星  
      

发表于 2007-5-28 13:10 
精彩.........................................................................................


只看该作者    顶部
离线 XXYXS
初级会员



精华贴数 0
个人空间 0
技术积分 14 (70608)
社区积分 0 (67181)
注册日期 2002-9-8
论坛徽章:0
      
      

发表于 2007-5-28 15:29 
实在精彩.........................................................................................


__________________
xieshi1999@hotmail.com13838413558实施服务
只看该作者    顶部
离线 ferryfu
版主



精华贴数 1
个人空间 0
技术积分 1062 (1791)
社区积分 6 (14597)
注册日期 2004-4-11
论坛徽章:8
现任管理团队成员管理团队2006纪念徽章2008北京奥运纪念徽章:跳水2008北京奥运纪念徽章:摔跤2008北京奥运纪念徽章:篮球2008北京奥运纪念徽章:足球
生肖徽章2007版:鸡ITPUB新首页上线纪念徽章    

发表于 2007-5-28 16:48 
仔细研究研究。


__________________
有志于Sap b1的人都是我的朋友。
只看该作者    顶部
离线 Franks
痛并快乐着


精华贴数 2
个人空间 316
技术积分 8191 (168)
社区积分 3273 (454)
注册日期 2002-2-5
论坛徽章:37
现任管理团队成员2009新春纪念徽章生肖徽章:龙生肖徽章:龙生肖徽章:龙生肖徽章:龙
生肖徽章:龙生肖徽章:龙    

发表于 2007-5-29 16:47 
呵呵...钻得真透!


__________________
Mail:我的用户名@itpub.net
MSN:iippv@hotmail.com(基本不上)
QQ :8822206(长期隐身)

水穷之处待云起,危崖旁侧觅坦途

我的地盘
只看该作者    顶部
离线 hhl_2008
一般会员



精华贴数 0
个人空间 0
技术积分 188 (10348)
社区积分 0 (1079629)
注册日期 2006-8-17
论坛徽章:1
2009新春纪念徽章     
      

发表于 2007-5-29 18:25 
哈,,,我也是前几天才知道这个功能了,所以很强大,顶上去


只看该作者    顶部
离线 akun
中级会员



精华贴数 0
个人空间 0
技术积分 374 (5456)
社区积分 5 (15820)
注册日期 2002-9-4
论坛徽章:0
      
      

发表于 2007-6-2 11:40 
这种思路很有启发,多谢了


只看该作者    顶部
离线 badboygsl
牧人



精华贴数 0
个人空间 0
技术积分 108 (16292)
社区积分 0 (944489)
注册日期 2006-5-19
论坛徽章:0
      
      

发表于 2007-6-3 11:00 
爽快,我喜欢.顶起


__________________
Q Q:19379090MSN:badboygsl@hotmail.com
只看该作者    顶部
相关内容


CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰网域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:060528号 联系我们 法律顾问