天天看點

CRM one order性能調優指南

要對基于one order framework進行性能調優,需要對one order framework的事件處理有一個最基本的了解。

我通過截圖列出了一些關鍵點,你看看根據這些資訊能不能自己找到問題的答案:

通過UI建立一個transaction type為TA的sales order為例:

CRM one order性能調優指南

transaction type TA對應的transaction category如下:

CRM one order性能調優指南

Order修改的所有操作都是通過FM CRM_ORDER_MAINTAIN 統一trigger:

CRM one order性能調優指南

最終會調用CRM_ORDER_H_MAINTAIN_OW 或者 CRM_ORDER_I_MAINTAIN_OW處理Header或者Item:

CRM one order性能調優指南

裡面的FM CRM_ORDERADM_H_PUBLISH_OW統一raise Order header level的各種事件,進而調用事件上注冊的callback。

CRM one order性能調優指南

在該function module内搜尋關鍵字 CRM_EVENT_PUBLISH_OW,能找出該FM 負責raise的所有支援的event:

CRM one order性能調優指南

internal table gt_allowed_callbacks_hdr 存放了目前系統注冊的所有call back資訊。系統理一次進入CRM_EVENT_PUBLISH_OW時,該内表是空的,通過subroutine register_callbacks 初始化。

CRM one order性能調優指南

目前建立的sales order

CRM one order性能調優指南

gt_pr_assign包含兩個從SPRO裡維護的category 再加上一個generic的BUS20001:

CRM one order性能調優指南

register完畢後針對transaction type TA,有411個可用的callback:

CRM one order性能調優指南
CRM one order性能調優指南

CRM_EVENT_PUBLISH_OW的執行邏輯就是找出這411個callback中有哪些是注冊在Order的header level,且event為after_create:

CRM one order性能調優指南

lv_guid_hdr: 新建立的sales order guid

lt_atonce_exets: 需要立即執行的function module name

CRM one order性能調優指南

真正的function module 執行發生在這裡:

CRM one order性能調優指南

Sent: Friday, August 15, 2014 5:36 PM

To: Wang, Jerry

Subject: 關于回調函數

首先,有幾個概念我有點混淆, call back是指回調函數,對嗎?也就是在SPRO裡, 最下面那個紅框EDIT EVENT Handler Table裡定義的

CRMV_EVENT is for predefined callbacks. The customer-defined callbacks should not be registered here. Move them to SPRO.

CRM one order性能調優指南

界面如下, 可以看到某個function 比如第3行 ZCRM_CP_PRIN0_ITMCHG_EC被注冊到了BUS200001這個general 類型上, immediately執行, event事件是在after_change,即發生改變就觸發這個函數,優先度為0,那就是先執行它, 後續可能其他function注冊為1,2,3,順序執行, 執行的觸發函數是下面界面的form execute_callbacks_planned; 因為item那項有勾, 隻執行ITEM level的也就是item發生改變時執行, header改變的時候不執行,不知道了解的對不對?

CRM one order性能調優指南

但是這個form execute_callbacks_planned的次數, 比如29次是由什麼決定的? 還有裡面的function, 比如第5行ZER1_YMRP_BTX_QUT_PRODOC_CHK_EC, 被執行了10次, 這是在哪裡決定的?

CRM one order性能調優指南

這個調用堆棧, 看來是由CRM_OREDER_MAINTAIN調到的

CRM one order性能調優指南

但是在call stack裡也見到了如下form EXECUTE_CALLBACKS_AT_ONCE, 它和上面的差別, 按字面是一個是plan, 一個是立即執行, 但是這是如何區分的? 程式如何知道

CRM one order性能調優指南

看起來也是由Execute_callbacks_planned 最終調用到了EXECUTE_CALLBACKS_AT_ONCE, 但是我不了解 的是那注冊在SPRO的那些回調函數到底是由哪個form真正調用的? 或者我的了解是不是已經方向性偏離了?

CRM one order性能調優指南

看以前同僚(已經離職, 最近兩年走了很多資深同僚, 想咨詢也很難了)寫的關于回調函數的注意點:

Consider the following:

Restrict the number of times the callback is planned in for a certain execution time to a minimum.

Register the callback for individual transaction categories instead of for the generic transaction category BUS20001 so that the callbacks do not run unnecessarily for other transactions.

Avoid register the unnecessary callbacks to transaction category BUS2000115 -------115 我知道是CRM Sales Transaction, 注冊FM在這個上面,是不是也相當于general的調用, 我看聯想很多fm都是注冊在這裡的,

CRM one order性能調優指南

Consider whether it is absolutely necessary to set the execution time “Immediately”. The other execution times are better for performance since several events might trigger the same callback.-----如果不設定成immediately,

CRM one order性能調優指南

還有很多選項, 這個完全得看業務需要和實際邏輯了。

Consider carefully which value you set for the parameter Call Callback and restrict the number of times the callback is planned in for a certain execution time to a minimum. ------這個是在哪裡設定????是我第一個界面嗎?如何限制調用次數?

繼續閱讀