什麼是BADI,如何從SAP中尋找BADI?

來源:互聯網
上載者:User

Business Add-Ins are a new SAP enhancement technique based on ABAP Objects. They can be inserted into the SAP System to accommodate user requirements too specific to be included in the standard delivery. Since specific industries often require special functions, SAP allows you to predefine these points in your software.

SAP預定義了一些Interface,客戶可以自己定義實現Interface的Class進行客戶化,在標準程式中會使用調用客戶自訂Class的 Instance,在擷取Instance的過程使用了原廠模式,因此擷取過程對使用者是未知的。不過BADI也有一些局限性,就是有哪些 Interface是固定死的,有的時候會發現需要Mix客戶化代碼的時候找不到Interface,什麼時候SAP的OO裡面直接支援AOP就好了。

如何從SAP中尋找BADI

BADI作為SAP的第三代使用者出口,他的應用也越來越廣泛,但如何找到合適的badi是許多abap程式員的困惑。我這裡就介紹一下我個人的應用的經驗,供大家參考。

1、badi對象的資訊儲存在SXS_INTER, SXC_EXIT, SXC_CLASS 和SXC_ATTR 這四個表中(參見SECE包);

2、sap程式都會調用cl_exithandler=>get_instance來判斷對象是否存在,並返回執行個體;其實get_instance就是對上述幾個表和他們的視圖(V_EXT_IMP 和 V_EXT_ACT)進行查詢和搜尋。

3、基於這個機理,我查用ST05來監控一個TCODE來跟蹤,然後選擇尋找有關上述幾個表和視圖的操作,就可獲得相關BADI。

 4、se18 尋找介面,se19 實現介面就可以實現使用者增強。
樣本:用LE_SHP_DELIVERY_PROC控制跨月Cancel

METHOD if_ex_le_shp_delivery_proc~change_delivery_header .
 DATA : thismonth(2) TYPE c.
 DATA : wa_likp TYPE LINE OF shp_likp_t.
 DATA : wa_log TYPE LINE OF shp_badi_error_log_t.
 CLEAR ct_log[],thismonth.
 thismonth = sy-datum+4(2). "----->這一個月的月份
 LOOP AT it_xlikp INTO wa_likp.
   CHECK is_v50agl-warenausg_storno ='X'."--->代表作GI cancel
   IF wa_likp-wadat_ist+4(2) < thismonth.
     wa_log-vbeln = cs_likp-vbeln.
     wa_log-msgty = 'E'. "錯誤訊息
     wa_log-msgid = 'ZDN_ERROR'. "這一個class要自己建
     wa_log-msgno = '001'.
     APPEND wa_log TO ct_log. "Error log寫入
   ENDIF.
 ENDLOOP.
ENDMETHOD. "IF_EX_LE_SHP_DELIVERY_PROC~CHANGE_DELIVERY_HEADER

TCODE:

SE18
SE19

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.