个人收藏 如何从SAP中查找BADI

来源:互联网 发布:铃声编辑软件 编辑:程序博客网 时间:2024/04/26 06:59

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.

 

 

这是一个比较详细的说明,给那个类加上断点之后,发现开发工具 像se24都用到了badi

 

1) Go to main program of the transaction.

Search for string 'Get_instance'. These are the places where BADIs are called.
This method will have a parameter for BADI name. There you can find which BADI is being called.

2) If you run a program indebug mode and set a break-point at the function module PF_ASTAT_OPEN, then press F6. This will stop at any BADIs'.

3) These steps should enable you to find any BADI related to any transaction in a matter of minutes.
i) Go to the transaction SE37 to find your function module.
ii) Locate the function SXV_GET_CLIF_BY_NAME.
iii)Put a breakpoint there.
iv) Now open a new session.
v) Go to your transaction.
vi) At that time, it will stop this function.
vii) Double click on the function field EXIT_NAME.
viii) That will give you name of the BADI that is provided in your transaction.

4) Find the Exact exits and badis for ur requirement.
How to fine the exact badi:
i) Goto se24 (Display class cl_exithandler)
ii) Double click on the method GET_INSTANCE.
iii) Put a break point at Line no.25 (CASE sy-subrc).
Now
iv) Execute any SAP standard transaction
v) Press the required button for which you need to write an exit logic, the execution will stop at the break point.
vi) Check the values of variable 'exit_name', it will give you the BADI name called at that time.
vii) This way you will find all the BADIs called on click of any button in any
transaction

Regards,
Rajesh Akarte

原创粉丝点击