Detailed Explanation About BADI and The Ways To Find The BADI With An Example (ME23n Transaction)
Detailed Explanation About BADI and The Ways To Find The BADI With An Example (ME23n Transaction)
Detailed Explanation About BADI and The Ways To Find The BADI With An Example (ME23n Transaction)
BADI (Business Add-In) is a new SAP Object Oriented enhancement technique which is used to add our own business
functionality to the existing SAP standard functionality.
BADI's are available in SAP R/3 from the system release 4.6c
Why BADI?
In contrast to the earlier enhancement techniques, BADI follows Object Oriented approach to make them reusable. A
BADI can be used any number of times where as standard enhancement techniques can be used only once.
For example if we assign an enhancement to one custom project, then that enhancement cannot be assigned to any
other custom projects. To overcome this drawback SAP has provided a new enhancement technique called BADI.
Transaction code for BADI Definition:
SE18
When you create a BAdI definition, a class interface will be automatically created and you can define your methods in
the interface. The implementation of the methods can be done in SE19 transaction.
When a BAdi is created following are automatically generated:
An interface with 'IF_EX_' inserted between the first and second characters of the BAdi name
An adapter class with 'CL_EX_' inserted between the first and second characters of the BAdi name.
Transaction code to Implement BADI:
SE19
Types of BADI's:
While creating a BADI using the T-code SE18, it provides the pop-up screen to select the type of BADI to be used is as
shown below.
4. Run any transaction on which we want find the BADI's say VA01.
7. You can find the BADI name in field EXIT_NAME and if you double click on it, we can get the corresponding BADI
name before hit the corresponding screen. Based on the requirement find the BADI name and accordingly implement
your functionality using the transaction se19.
Method 2:
Go to transaction SE84 and click on Enhancements. Then double click on Business Add-Ins.
For example, if you want to find the BADI's for the standard transaction ME22n, the procedure is as follows. This
example shows, finding the way of BADI names by providing the Package of ME22n.
1)
Go to transaction ME22n. Select the System option from the menu and then click on Status. It displays the
following information.
2)
Double click on the program name i.e. SAPLMEGUI. It will take you into the program and click on Go to tab from
the Menu. There we can find the package name of the standard transaction ME22n.Copy and paste it in the package
filed.
3)
Now Press F8, a list of BADI names will be displayed as shown below. Select the appropriate BADI name and
Method 3:
Finding the BADI names using SE18 transaction
1)
Go to transaction SE 18. Select F4 help for the definition name and click on Information System button as shown
below.
2)
A pop-up screen will be displayed and give the package name for any standard transaction say VA02. Finding the
package is explained above. Please refer above method to find the package name. The package name for VA02
transaction is 'VA.'
3)
A list of BADI names will be displayed for the transaction VA02. Select the appropriate BADI name and implement
Example:
This Example explains how to implement BADI's. Here I am trying to show how to add custom screen to
the ME23N Transactions using BADI's.
The procedure is as explained below.
-
Go to T-code SE19 and create an implementationZME_GUI_PO_CUST and then click on create button
Give the Definition name "ME_GUI_PO_CUST" and continue, give short text, save
Click on Interface Tab, you can find the implementation class name asZCL_IM_ME_GUI_PO_CUST2.
'ITEMSCREEN1 '.
-
Go to the code section of the method and add the following code there.
Code for IF_EX_ME_GUI_PO_CUST~SUBSCRIBE:
DATA: ls_subscriber LIKE LINE OF re_subscribers.
*--FIRST SCREEN POPULATION
*--we want to add a customer subscreen on the item detail tab
CHECK im_application = 'PO'.
CHECK im_element
= 'ITEM'.
<mapping>-metafield = mmmfd_cust_08.
WHEN 'MTART'.
<mapping>-metafield = mmmfd_cust_09.
WHEN 'MATKL'.
<mapping>-metafield = mmmfd_cust_10.
ENDCASE.
ENDLOOP.
The metafield mapping important for field selection and error handling purpose.
Now Create a Program with the Name 'ZME_GUI_PO_CUST_SCREEN' and create a screen with sub screen type with
the number 0002.
**
De comment the PBO module in screen flow logic and create the module in above program.
Add the following code in program ZME_GUI_PO_CUST_SCREEN.
TABLES: ZMARA.
DATA: call_subscreen TYPE sy-dynnr,
call_prog TYPE sy-repid,
call_view TYPE REF TO cl_screen_view_mm,
call_view_stack TYPE REF TO cl_screen_view_mm OCCURS 0.
*---------------------------------------------------------------------*
*
FORM SET_SUBSCREEN_AND_PROG
*---------------------------------------------------------------------*
*
........
*---------------------------------------------------------------------*
* --> DYNNR
* --> PROG
* --> VIEW
* --> TO
* --> CL_SCREEN_VIEW_MM
*---------------------------------------------------------------------*
FORM set_subscreen_and_prog USING dynnr TYPE sy-dynnr
prog TYPE sy-repid
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE STATUS_0002 OUTPUT.
SELECT SINGLE * FROM MARA
INTO CORRESPONDING FIELDS OF ZMARA
WHERE MATNR = '100-100'.
ENDMODULE.
You can find a new tab is added in the item level with the name CUST BADI.
Final Output: