1 of 27

� �Introducing the Enhancement Framework�(BADI Development)

Anthony Cecchini

Information Technology Partners Consulting

2 of 27

Objectives

The Objective for this session is to:

    • Educate RICEFW team members responsible for creating extensions to the delivered SAP standard code, specifically calling out the use of both Classic and Kernal Badi’s

The purpose of this presentation is to:

    • Provide an Overview of the Enhancement Framework
    • Describe what a BADI is……
    • Classic vs. Kernel BADI’s
    • Implement a BADI (Classic)
    • Tips & Tricks
    • Address feedback and questions from Audience

www.itp-consulting.com

3 of 27

Enhancement Framework

  • SAP is known for delivering business software easily adaptable by customers for their specific needs. Typically the software (for example, mySAP ERP) can be adapted by one of the following techniques: �
    • Customizing (defining system behavior through standard SAP provided mechanism without coding), �
    • Enhancement (adding custom code at strategic hook positions provided by SAP) �
    • Modification (modifying SAP supplied code directly – often called Core-Mod ��.

www.itp-consulting.com

4 of 27

Enhancement Framework

  • Let us first take a look at how the enhancement technique has evolved so far in SAP.

  • User-Exit’ is one of the very first mechanisms provided by SAP to execute custom code in between the standard SAP control flow. This is implemented as subroutine call (PERFORM xxx). A classical example for User-Exit is MV45AFZZ include in order processing module of SAP R/3. Though this include object doesn’t fall under customer namespace, the object doesn’t get overwritten during upgrade. �
  • Customer-Exit’ is better than the user-exit, in the sense that it is implemented using Function Modules and so has a well defined parameter interface. Also since the custom coding done as part of these customer-exits is located away from the original SAP code, the maintenance is easier than user-exits. �
  • The ‘BADI-s’ (Business Add-Ins), as they exist in pre NW04s releases are now called old classic-BADI’s. This was the first object-oriented way to enhance the ABAP system. This, to a certain extent, allows multiple implementations with limited filter support. The classic-BADI’s are implemented using ABAP Objects

www.itp-consulting.com

5 of 27

Enhancement Framework

  • So what's so cool about this new enhancement technology?

    • Source Code enhancement
    • Function Group enhancement
    • Class enhancement
    • Kernel-BADI Enhancement

  • The first three methods, viz., Source Code enhancement, Function Group enhancement, and Class enhancement are brand new ways to enhance the ABAP system. The final one Kernel-BADI is an improvement of the old classic-BADI now integrated into the Enhancement Framework. Remember that all of these techniques are considered enhancing and not modifying the system.

www.itp-consulting.com

6 of 27

What is a BADI?

  • Business Add In

    • Business Add-Ins may be simply defined as an object-oriented extension of the SAP. They consist of special hooks provided by SAP core developers for incorporating customer (or company) specific logic. (BADI Definition) The process of adapting your program according to your specific scenario is known as implementation of the BADI.

    • BADIs are based upon the concept of object-orientation. The program that incorporates the enhancement option calls a method of a generated BADI class. During the implementation procedure, the customer-specific code is written in the relevant method. The method name is specified via a BADI interface. The name of the interface is of the form IF_EX_BADI, where BADI is the name of the Business Add-In in question. For example, in the case of the HR Add-In HR_INDVAL, the involved interface is IF_EX_HR_INDVAL.

www.itp-consulting.com

7 of 27

What is a BADI?

www.itp-consulting.com

BADI Architecture in SAP

What's important about this diagram is that it reflects both the definition of a classic BADI as well as it’s implementation.

8 of 27

What is a BADI?� (Definition)

www.itp-consulting.com

1.CORE SAP Application developers define an interface for the� add-in

2.SAP generates an adapter class for implementing the add-in � thus opening a path for customer or partner implementations

BADI Architecture in SAP

1

2

9 of 27

What is a BADI? �(implementation)

www.itp-consulting.com

1.Customer/partner developer creates an interface of the adapter class

2.The interface definition ensures that consistent data is passed to the� different add-in implementations

3.Adapter class takes care of calling and filtering out the proper � components

BADI Architecture in SAP

1

3

2

10 of 27

What is a BADI?

  • SAP guarantees upward compatibility of all BADI interfaces
  • BADIs are not a replacement for Customer Exits (already existing exits were not converted to BADIs)
  • Enhancements, interfaces & generated classes all lie in the SAP namespace
  • Implementations lie in the customer/partner namespace and are transportable
  • Standard naming conventions apply for BADIs – start your implementations with Z
  • Object oriented coding rules apply (i.e. – no header lines on internal tables)

www.itp-consulting.com

  • If an BADI is called frequently, performance problems can occur

(No longer an issue with new Kernel BADI’s)

  • Customers can create BADIs
  • Creating a BADI within a CMOD project exit can allow multiple developers to share an exit without stepping on each other’s toes

11 of 27

Classic vs. Kernel BADI’s

  • The old classic-BADI’s are implemented purely at the ABAP Workbench level; that is, both the definition and implementation are realized as workbench repository objects (global classes and interfaces).. �� Example:

.

www.itp-consulting.com

12 of 27

Classic vs. Kernel BADI’s

  • The new Kernel-BADI takes it to the ABAP language level. Because of this, the new Kernel-BADI’s are much faster compared to the old classic-BADI’s
  • There are two new ABAP statements available now to support the Kernel-BADI’s, namely GET BADI and CALL BADI.

Example:

data bd_hdl type ref to badi_name.

GET BADI bd_hdl filters filt_1 = ‘VALUE’.

CALL BADI bd_hdl->method

exporting param_1 = 10.

www.itp-consulting.com

13 of 27

Classic vs. Kernel BADI’s

  • The old classic-BADI used to mix both implementation selection and method call in the same CALL METHOD statement. The implementations could only be chosen at run-time because of the above reason and due to the fact that the BADI handle could only be gotten from another method call by passing the BADI name. �
  • Whereas in the new Kernel-BADI, the active BADI implementations are included into the load of BADI handle at compile time and the filter criterion are expanded as IF statements. This is the reason the new Kernel-BADI’s are much faster than classic-BADI’s.

  • Some of the other new features of Kernel-BADI’s are,
    • • Improved Filters with complex filter condition editor
    • • Possibility to inherit the implementations
    • • Switchable using Switch Framework

www.itp-consulting.com

14 of 27

Implement a BADI (Classic)

Step 1: Creating an Implementation

  • The first step involves creating a BADI implementation. Call transaction SE19. The BADI implementation screen appears, as shown. Enter a suitable name for your implementation in the field provided, and click the Create button

www.itp-consulting.com

15 of 27

Implement a BADI (Classic)

  • A pop-up screen appears, as shown. Enter the name of the BADI involved and press the Enter button.

www.itp-consulting.com

16 of 27

Implement a BADI (Classic)

  • Enter an appropriate short text in the field provided. Then, click on the Interface tab. This shows the name of the class that will be generated as a result of the implementation. You may change the class if you like. The Interface tab also contains the name of the BADI method.

www.itp-consulting.com

17 of 27

Implement a BADI (Classic)

  • Then, double-click on the name of the method (in our case SAP_SCRIPT_TABLES). This takes you to the Class Builder’s method editor screen. This is the area where you may write the code that you would like to be executed when the BADI method is called

www.itp-consulting.com

18 of 27

Implement a BADI (Classic)

Step 2: Writing the code for the BADI Method

  • The next step is to write the appropriate coding for the BADI method. This code incorporates the enhancement logic and is executed by the application program upon the BADI method call. Most of the ABAP statements are applicable in this case. However, since the BADI technology is based upon ABAP Objects, some ABAP constructs are not allowed.
  • The method has importing, exporting, and changing parameters. The enhancement may be achieved by writing code that assigns suitable values to the changing and exporting parameters of the method. The main application program uses these values for further processing, and in this way the desired enhancement effect is achieved

www.itp-consulting.com

19 of 27

Implement a BADI (Classic)

Step 2: Activate the BADI!

www.itp-consulting.com

20 of 27

Tips & Tricks

  • How do we find available BADI’s?

�There are multiple ways of searching for BADI’s. First there is the obvious……

    • Go to Transaction Code SE18 (Definition)�
    • Press F4�
    • Search by package, Hierarchy, or by program.

www.itp-consulting.com

21 of 27

Tips & Tricks

  • Finding BADI Using CL_EXITHANDLER=>GET_INSTANCE

    • Go to the Transaction, for which we want to find the BADI. Click on System->Status.

    • Double click on the program name. �
    • Once inside the program search for CL_EXITHANDLER=>GET_INSTANCE’.�
    • Make sure the radio button “In main program” is checked.

    • A list of all the programs with call to the BADI’s will be listed.�
    • The export parameter ‘EXIT_NAME’ for the method GET_INSTANCE of class CL_EXITHANDLER will have the METHOD assigned to it. The changing parameter ‘INSTANCE’ will have the interface assigned to it. �
    • Double click on the method to enter the source code.

www.itp-consulting.com

22 of 27

Tips & Tricks

  • Finding BADI Using SQL Trace (TCODE-ST05)

  • Start transaction ST05 (Performance Analysis).�
  • Set flag field "Buffer trace" �Remark: We need to trace also the buffer calls, because BADI database tables are buffered. (Especially view V_EXT_IMP and V_EXT_ACT)�
  • Push the button "Activate Trace". Start transaction in a new GUI session. Go back to the Performance trace session. �
  • Push the button "Deactivate Trace".�
  • Push the button "Display Trace".�
  • The popup screen "Set Restrictions for Displaying Trace" appears.�Now, filter the trace on Objects: �• V_EXT_IMP �• V_EXT_ACT�
  • Push button "Multiple selections" button behind field Objects �Fill: V_EXT_IMP and V_EXT_ACT �All the interface class names of view V_EXT_IMP start with IF_EX_. This is the standard SAP prefix for BADI class interfaces. The BADI name is after the IF_EX_.�

So the BADI name of IF_EX_CUSTOMER_ADD_DATA is CUSTOMER_ADD_DATA

www.itp-consulting.com

23 of 27

Tips & Tricks

  • Finding BADI Using Repository Information System (TCODE- SE84)

    • Go to “Maintain Transaction” (TCODE- SE93).�
    • Enter the Transaction for which you want to find BADI.�
    • Click on the Display push buttons.�
    • Get the Package Name. �
    • Go to TCode: SE84->Enhancements->Business Add- � inns->Definition, enter the Package Name and Execute.��Here you get a list of all the Enhancement BADI’s for the given package

www.itp-consulting.com

24 of 27

Conclusion

  • I reviewed the rudiments of Business Add-Ins and their benefits for SAP users and developers. Then, I discussed in detail the steps required in implementing an add-in. �
  • I hope this presentation will provide you with some breadcrumbs to help you in adapting standard SAP programs quickly and easily using BADI’s!

www.itp-consulting.com

25 of 27

Further Information

  • Help Portal

http://help.sap.com

Documentation SAP Netweaver (04s) Application Platform

ABAP technology ABAP Workbench Enhancement Framework

  • SDN

http://sdn.sap.com

www.itp-consulting.com

26 of 27

Address Feedback & Questions �from audience

www.itp-consulting.com

27 of 27

Copyright 2007 , �All Rights Reserved

www.itp-consulting.com