You are on page 1of 13

Int rod uc tio n

BADI implementation in the MM02 transaction to change the material description.When the customer needs more
functionality in the SAP standard Program (Functionality) then we can add extra functionality to standard SAP functionality
through BADI. BADI can't disturb the original (standard) code.
Adding extra functionality to the standard is nothing but Add-in.
BADI are not created in the program itself. They are created and maintained separately and called when we need the BADI.
In the given tutorial BADI implantation of transaction MM02 is done as to change the description of the material number, for
that I have explained the way to find the appropriate BADI according to the requirement.
Than we will learn to see all the methods associated with that BADI name and finally implement that BADI to add extra
features.
Steps t o find BADI
Run the transaction SE2 4. Under object type put the class name 'CL _EXITHANDLER' .
Click on display button.

Under this class 'CL_E XITHANDLER' select the method 'GET_INST ANCE' and double click on it.

Under the method 'GET_INST ANCE' put break point on a function module called
'CAL L ME THOD CL _EXITHANDLER=>GE T_ CL ASS_NAM E_ BY_INTERF ACE'
Place the cursor over here and give a break point.

Then according to the requirement run the transaction. In this example transaction code is MM02 .
Run the transaction MM02. As in 1st step we have put a break point, that function module will give all BADI used by the
transaction in each screen and activity on the application (MM02).
Now double click on the changing parameter EXIT_NAM E of the function module to get the name of BADI used in this
transaction.
Now press F8 to again and again to get the list of all the BADI.
We will get following BADI as shown below.
BADI_ SCREE N_ LOGIC _R T
W_RET AILSY STE M_IDENT
BADI_MA TN1
Than again pressing F8 key the initial screen of transaction MM02 will appear.

Get a material number using F4 help and press enter.


BADI name after calling the main screen of MM02.

BADI_MA TERIAL_OD .

Now press F8 you will get the following screen.


Choose the basic data and press enter to proceed.

Press F8.

Press F8.
ECM_EXIT (Customer Exits for Engineering Change Management)
Press F8.
BADI_LAYER (Layer Value Management for BADIs)
Press F8.
BADI_MATERIAL_OD (Integration of New Objects in Material or Article Master)
Press F8.
BADI_MAT_F_SPEC_SEL (BADI for Material Special Field Selection)
Press F8.
Change material window will come. In this change the material description.
And savethe changes.You will get the following BADI.

BADI_GTIN_VARIANT (User Exit for Customer-Specific GTIN Variant Check)


Press F8.

BADI_MATERIAL_CHEK (Enhanced Checks for Material Master Tables)


Press F8.
BADI_MAT_F_SPEC_SEL (BADI for Material Special Field Selection)
Press F8.

EHSS_SPEC_CHECKS (BADI: Extended Checks for Specifications)


BADI name:
BADI_GTIN_V ARIAN T
BADI_MA TERIAL_C HECK
BADI_MA T_ SPEC_SE L
EH SS_ SPEC_C HECKS
Step to c he ck all t he me th ods as so ciat ed wit h tha t BADI
Run the transaction SE1 8 to see the details of BADI.

Click on display button to see the methods declared in that.


Click on the interface tab to see the details of all the methods associated with the BADI name as shown below.
Method CHECK_DATA is used to give the material description. Choose the method where the material description is
defined.

Steps t o imple me nt th e BADI


Run the transaction SE1 9 (BADI Bui lder) and create an implementation for the corresponding BADI. Click on create
button to create an implementation.
Give a name for the implementation.

Give the BADI description as shown below.


Double click on method CHECK _DA TA. On double clicking system will provide you the editor to write the code.

Write the code in the editor window as shown below.


The ent ire code is w ritten as show n below
CONSTANTS: wl_prefix(6) TYPE c VALUE 'LT_BD_',
wl_uname TYPE sy-uname VALUE 'EI6DEV'.
DATA: int_stext TYPE TABLE OF short_desc.
DATA: wa_stext TYPE short_desc.
DATA: wf_idx TYPE sy-tabix.
DATA: WA1 TYPE SHORT_DESC.
DATA: WA TYPE SHORT_DESC.
WA-MAKTX = 'HELLO'.
LOOP AT STEXT INTO WA1.
CONCATENATE WA1-MAKTX WA-MAKTX INTO WA1-MAKTX.
MODIFY STEXT FROM WA1.
ENDLOOP.
IF sy-uname = wl_uname. "and sy-tcode = 'MM02'
int_stext[] = stext[].
READ TABLE int_stext INTO wa_stext WITH KEY spras = sy-langu.
IF sy-subrc = 0.
wf_idx = sy-tabix.
IF wa_stext-maktx+0(6) = wl_prefix OR wa_stext-maktx IS INITIAL.
EXIT.
ELSE.
CONCATENATE wl_prefix wa_stext-maktx INTO wa_stext-maktx.
MODIFY int_stext FROM wa_stext INDEX wf_idx.
stext[] = int_stext[].
ENDIF.
ENDIF.
ENDIF.
Save the changes and activate the program. Than activate the BADI implementation.
The output of the BADI implementation is as shown below. The material description has been changed with the
prefix LT_BD_ .

This is how we can change the standard material description using BADI.

You might also like