SAP Badi Application

Source: Internet
Author: User
[Post] sap Badi Application

1. Define Badi
1) T-code: se18 business add-in define.

2) enter the name of the Badi you want to create and click "CREATE ".

3) enter the descriptive text of Badi, enter the interface name on the "interface" tab, or use the name of the interface recommended by SAP. At the same time, the Badi class will also be created.

For example, for Badi "ztest", SAP recommends "zif_ex_test" as the interface name and "zcl_ex_test" as the class name.

4) Save Badi.

5) double-click the interface name to jump to the class builder interface, where you can define the interface method.

6) Save and activate the interface.

2. Implement Badi
1) T-code: se19 business add-in implementation
2) enter the Badi implementation name and click "CREATE ".
3) enter the name defined by Badi.
4) enter the descriptive text of the implementation, and enter the name of the implementation class on the "interface" tab. The recommended sap name can be used.

For example: "zimptest", SAP will recommend "zcl_im_imptest ".

5) Save the implementation.

6) double-click a method name to jump to the class builder interface. Here you can addCodeTo redefine interface methods.

7) activation implementation.

3.ProgramBadi

1) first use the type reference to reference the Badi to be called
2) instantiate Badi
3) after instantiation, you can call the methods in Badi at will.

Report zzw_bapi_01.

Data exit type ref to zif_ex_zw_bd_test.

Call method cl_exithandler => get_instance
Changing
Instance = exit.

Call method exit-> z_zw_01.

="
Badi note
As the third-generation user exit of SAP, Badi has become more and more widely used. However, it is confusing for many ABAP programmers to find the right Badi. Here I will introduce my personal application experience for your reference.

1. Information of Badi objects is stored in four tables: sxs_inter, sxc_exit, sxc_class, and sxc_attr (see the SECE package );

2. the sap program will call cl_exithandler => get_instance to determine whether an object exists and return an instance. In fact, get_instance is used to view the tables and their views (v_ext_imp and v_ext_act) query and search.

3. Based on this mechanism, I checked and used st05 to monitor a tcode for tracking. Then I chose to find the operations on the tables and views above to obtain the relevant Badi.

4. You can use the se18 lookup interface and se19 interface to enhance user experience.
Example: Use le_shp_delivery_proc to control the cross-month 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). "-----> month of this month
Loop at it_xlikp into wa_likp.
Check IS_V50AGL-WARENAUSG_STORNO = 'x'. "---> stands for GI cancel
If wa_likp-WADAT_IST + 4 (2) <thismonth.
Wa_log-VBELN = cs_likp-vbeln.
Wa_log-MSGTY = 'E'. "error message
Wa_log-MSGID = 'zdn _ error'. "This class should be built by yourself
Wa_log-MSGNO = '001 '.
Append wa_log to ct_log. "Error Log write
Endif.
Endloop.
Endmethod.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.