Defining and Implementing Business Addins

Embed Size (px)

Citation preview

  • 8/6/2019 Defining and Implementing Business Addins

    1/19

    Defining andImplementing BusinessAddins (BADIs)

    White Paper

    Himanshu Kanekar

    SAP ABAP

  • 8/6/2019 Defining and Implementing Business Addins

    2/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 2

    Copyright 2006, Tata Consultancy Services Limited.

    All rights reserved.

    The contents hereof are the sole and exclusive property of Tata Consultancy Services

    Limited ('TCS') and may not be, for whatsoever purpose, reproduced, stored, copied or

    archived in any manner whatsoever either in full or in parts without the prior express

    consent of TCS.

    The contents hereof are purely for internal circulation in TCS and any access of

    whatsoever nature of these materials outside the TCS network is strictly prohibited and

    will attract legal liability of both civil and criminal nature. Any access of these materials

    outside the TCS network amounts to an act of infringement of the intellectual and other

    proprietary rights of TCS.

    Confidentiality Statement

  • 8/6/2019 Defining and Implementing Business Addins

    3/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 3

    Abstract

    BADI Business Add Ins are enhancements to the standard version of the code of SAP. They

    can be inserted into the SAP system to accommodate user requirements too specific to be

    included in the standard delivery. Customers can find the possible enhancements (BADIs) in their

    SAP system in the Implementation Guide (IMG) and in the component hierarchy. BADI definitions

    are included in the IMG so that the customer can create suitable, company-specific

    implementations. SAP guarantees the upward compatibility of all Business Add-In interfaces.

    Release upgrades do not affect enhancement calls from within the standard software nor do they

    affect the validity of call interfaces.

  • 8/6/2019 Defining and Implementing Business Addins

    4/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 4

    About the Author

    Himanshu Kanekar is a SAP Certified ABAP Technical Consultant with TCS, India, with more

    than 4 years of experience in SAP Implementation and Support projects. He has worked in

    technical areas like ABAP, HR ABAP and BSP and functional areas like Human Capital

    Management (HCM), Material Management (MM), Finance (FI) and Project Systems (PS).

    About the Domain

    SAP (Systems, Applications and Products in Data Processing) is a standard business application

    software system that integrates all business processes and systems into one seamless and

    efficient framework. SAP R/3 is designed to support complete business management tasks of a

    corporation, company or institution.

    It is used in business systems to handle Invoice Payment, Production Resource Management

    and Financial Account Control. These specific tasks are accomplished by employing application

    modules, often described with acronyms such as MM (Materials Management) and SD (Sales

    and Distribution). The software is highly customizable using SAP's proprietary programming

    language, ABAP/4 (Advanced Business Application Programming).

  • 8/6/2019 Defining and Implementing Business Addins

    5/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 5

    Contents

    Introduction ........................................................................................................ 6

    Business Add-ins .............................................................................................. 6

    Definition of a BAdI ........................................................................................... 6

    Implementation of a BAdI ................................................................................. 7

    Steps for Defining and Implementing Business Add-ins ................................ 8

    Steps for Defining BADI .................................................................................... 8

    Steps for BADI Implementation ...................................................................... 11

    How to find Business Add-ins for a Transaction Code................................. 16

    Steps to find Business Add-ins for a Transaction ........................................... 16

    Conclusion ........................................................................................................ 17

    Acknowledgements ......................................................................................... 18

    References ........................................................................................................ 19

  • 8/6/2019 Defining and Implementing Business Addins

    6/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 6

    Introduction

    Business Add-ins

    BADI Business Add-Ins are enhancements to the standard version of the code of SAP. They

    can be inserted into the SAP system to accommodate user requirements too specific to be

    included in the standard delivery. Customers can find the possible enhancements (BADIs) in their

    SAP system in the Implementation Guide (IMG) and in the component hierarchy. BADI definitions

    are included in the IMG so that the customer can create suitable, company-specific

    implementations. SAP guarantees the upward compatibility of all Business Add-In interfaces.

    Release upgrades do not affect enhancement calls from within the standard software nor do they

    affect the validity of call interfaces.

    Two different views are available:

    Definition View: In the definition view, an application programmer defines exit points in a source

    that allow specific industry sectors, partners, and customers to attach additional coding to

    standard SAP source code without having to modify the original object.

    Implementation View: In the implementation view, the users of Business Add-Ins can customize

    the logic they need or use a standard solution if one is available.

    Definition of a BAdI

    SAP application developer actually defines a Business Add-In available to an application

    program. Transaction Code SE18 can also be used to see the definition of existing BAdi.

    The following are the steps in defining a BADI:

    Using the SAP BADI builder, the SAP application developer defines an enhancement (BADI).

    It consists of an interface with a method.

    The interface name is generated automatically and can be changed. The system branches to

    the Class Builder.

    Using the Class Builder, the developer assigns a method to the interface.

    For each method, he defines parameters. Parameters can either be importing or changing

    and these are the fields available for customer to use for enhancements. Importing

    parameters are the fields being passed from the calling program and changing parameters

    are the fields being passed back to the program.

    The Business Add-In is then activated in the Class Builder.

  • 8/6/2019 Defining and Implementing Business Addins

    7/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 7

    Note: Documentation of the BADI usually provides the list of parameters and their definition.

    For example, for method DETERMINE_EXTPO, the available parameters are:

    Importing

    o ITEM_DATA Item data (is a structure)

    Changing

    o BBP_EXTPO_GL

    o If the field has the value X, the request is subject to the extended classic scenario.

    o If the field is empty, the request is not subject to the extended classic scenario.

    Implementation of a BAdI

    If a customer wishes to use a Business Add-In, he or she first creates an implementation. The

    customer must implement the methods and the enhancements. You need to program the

    interface method in such a way that, when the add-in is called from the application program, it willperform the specific action the customer intends.

    The following are the steps customer can follow in implementing a BADI:

    In the SAP menu, choose ABAP Workbench Utilities Business Add-Ins (Transaction

    SE19) or double-click the corresponding activity in the Implementation Guide (IMG).

    Enter a name for the implementation and then click the Create pushbutton.

    Enter the name of the add-in for which you want to create an implementation for in the dialog

    box that appears. Choose the Interface tab.

    Choose ABAP Code as the Implementation Type.

    Navigate to the Class Builder by double-clicking the method. You must first enter a package

    before the Class Builder is displayed.

    Insert the desired source code for the implementation between the method

    if_ex_businessaddin~method and endmethod (statements that already exist). You need to

    use the parameters (importing and changing) as fields within the BADI. You can define

    additional fields you need in the coding as local data fields.

    Save your entries and return to the Change Implementation screen.

    Choose Activate. The enhancements active components are then called at runtime.

  • 8/6/2019 Defining and Implementing Business Addins

    8/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 8

    Steps for Defining and Implementing Business Add-ins

    Steps for Defining BADI

    Go to transaction SE18 and create a BADI Definition.

    Click on Create. The following screen would be displayed wherein you enter the description of the

    definition. The name of the interface will be automatically proposed.

    Save

  • 8/6/2019 Defining and Implementing Business Addins

    9/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 9

    Double click on the interface YIF_EX_HK_GET_MATDATA.

    Enter the name of the method you want to create.

    Click the Parameters pushbutton to create parameters for the method.

  • 8/6/2019 Defining and Implementing Business Addins

    10/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 10

    Save and activate it.

  • 8/6/2019 Defining and Implementing Business Addins

    11/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 11

    Steps for BADI Implementation

    This can be done in any of the following way:

    (a) On the menu bar of the initial screen of SE18 Enter the BADI Definition Name.

    In the Implementation Menu Create.

    Enter the Implementation name. Press enter

    (b) Or go to Transaction Code SE19.

  • 8/6/2019 Defining and Implementing Business Addins

    12/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 12

    A popup window will ask you for the definition name. Enter the name of the BADI definition which

    you have created.

    Press Enter.

    Enter the description for the implementation. Then save and activate it.

    Double click on the method name.

    Write the following code. Save and activate it.

  • 8/6/2019 Defining and Implementing Business Addins

    13/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 13

    Activate the BAdi Implementation.

  • 8/6/2019 Defining and Implementing Business Addins

    14/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 14

    Now create the following code, using the created BADI

    Note: The above example is Single implementation. Formultiple implementations, define an

    add-in and select the Multiple Use checkbox from theAttributes tab.

  • 8/6/2019 Defining and Implementing Business Addins

    15/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 15

    We can differentiate between single-use and multiple use Business Add-Ins. The distinction is

    based on the procedure or event character of an enhancement. In the first case, the program

    waits for the enhancement to return something, usually a return code. A typical example could be

    a benefit calculation in HR. Depending on the implementation, alternative calculations can be

    executed.

    With multiple use Add-ins, an event that may be of interest to other components is processed in

    program flow. Any number of components could use this event as a hook to hang their own

    additional actions on to.Note: The system does not check whether the class or method specified in BADI implementation

    actually exists. If a class or method does not exist, a runtime error occurs when using the function

    in the formula builder.

  • 8/6/2019 Defining and Implementing Business Addins

    16/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 16

    How to find Business Add-ins for a Transaction Code

    Steps to find Business Add-ins for a Transaction

    1. Open Transaction SE24 (Class Builder).

    2. Now open the object CL_EXITHANDLER in display mode.

    3. Go to the method tab and double click on the method GET_INSTANCE.

    4. Put a break point on cl_exithandler=>get_class_name_by_interface.

    5. Now execute the transaction you want to find EXIT for, it will take you to the above method.

    6. Write EXIT_HANDLER in fieldnames and hit enter, it will tell you the EXIT used for your

    transaction.

    7. Hit F8 and it you will get the EXITs for your transaction.

    Another technique to find the BADI attached to a Transaction Code is:

    Go to Transaction Code SE15 --> Expand Enhacements Tab --> Expand Business Addins -->

    Enter Package attached to Transaction Code (you can see the Package for a Transaction in

    SE93 ) and execute.

    You will find the BADI attached to Transaction Code.

  • 8/6/2019 Defining and Implementing Business Addins

    17/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 17

    ConclusionThis document explains the concept of Business Add-ins and its use. It also describes the step by

    step approach of defining and implementing a Business Add-in in an ABAP program and also the

    steps to find the BAdis for a SAP Transaction Code. Using Business Add-ins, one can customize

    or enhance the standard SAP Functionality to suit the clients needs.

  • 8/6/2019 Defining and Implementing Business Addins

    18/19

    Defining and Implementing Business Addins (BADIs)

    Confidential 18

    Acknowledgements

    I express my gratitude and thanks to the organization (Tata Consultancy Services Limited) for the

    opportunities and infrastructure provided to create this document.

    I also want to express my thanks to the SAP help portal and SAP Developers Network for various

    post related to Business Add-ins.

  • 8/6/2019 Defining and Implementing Business Addins

    19/19

    Defining and Implementing Business Addins (BADIs)

    References

    SAP Help Portal (Business Add-ins)

    http://help.sap.com/saphelp_nw04/helpdata/en/eb/3e7cf4940e11d295df0000e82de14a/frameset.htmSAP Techies

    http://www.saptechies.com/simple-sap-badi-example/\

    http://help.sap.com/saphelp_nw04/helpdata/en/eb/3e7cf4940e11d295df0000e82de14a/frameset.htmhttp://help.sap.com/saphelp_nw04/helpdata/en/eb/3e7cf4940e11d295df0000e82de14a/frameset.htmhttp://www.saptechies.com/simple-sap-badi-example//http://www.saptechies.com/simple-sap-badi-example//http://help.sap.com/saphelp_nw04/helpdata/en/eb/3e7cf4940e11d295df0000e82de14a/frameset.htm