19644240 Badi Example

Embed Size (px)

Citation preview

  • 8/8/2019 19644240 Badi Example

    1/13

    Int rod uc tio nBADI implementation in the MM02 transaction to change the material description.When the customer needs morefunctionality in the SAP standard Program (Functionality) then we can add extra functionality to standard SAP functionalitythrough 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, forthat 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 extrafeatures.

    Steps t o find BADIRun 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_ CLASS_NAM E_BY_INTERF ACE'

  • 8/8/2019 19644240 Badi Example

    2/13

    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 1 st step we have put a break point, that function module will give all BADI used by thetransaction 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 thistransaction.

  • 8/8/2019 19644240 Badi Example

    3/13

    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 _RTW_RET AILSY STE M_IDENTBADI_MA TN1Than 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.

  • 8/8/2019 19644240 Badi Example

    4/13

    Choose the basic data and press enter to proceed.

    Press F8.

    Press F8.

  • 8/8/2019 19644240 Badi Example

    5/13

    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.

  • 8/8/2019 19644240 Badi Example

    6/13

  • 8/8/2019 19644240 Badi Example

    7/13

    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.

  • 8/8/2019 19644240 Badi Example

    8/13

    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 TBADI_MA TERIAL_C HECKBADI_MA T_SPEC_SE LEHSS_SPEC_C HECKS

    Step to c he ck all t he me th ods as so ciat ed wit h tha t BADIRun 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.

  • 8/8/2019 19644240 Badi Example

    9/13

    Method CHECK_DATA is used to give the material description. Choose the method where the material description isdefined.

    Steps t o imple me nt th e BADIRun the transaction SE1 9 (BADI Bui lder) and create an implementation for the corresponding BADI. Click on createbutton to create an implementation.

  • 8/8/2019 19644240 Badi Example

    10/13

    Give a name for the implementation.

    \

    Give the BADI description as shown below.

  • 8/8/2019 19644240 Badi Example

    11/13

    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.

  • 8/8/2019 19644240 Badi Example

    12/13

    The ent ire code is written as show n belowCONSTANTS: 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.

  • 8/8/2019 19644240 Badi Example

    13/13

    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 theprefix LT_BD_ .

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