enhancement framework_badi development

27
www.itp-consulting.com Introducing the Enhancement Framework (BADI Development) Anthony Cecchini Information Technology Partners Consulting

Upload: balamurugan-veerappan

Post on 08-Apr-2015

748 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Enhancement Framework_BADI Development

www.itp-consulting.com

Introducing the Enhancement

Framework(BADI Development)

Anthony CecchiniInformation Technology Partners Consulting

Page 2: Enhancement Framework_BADI Development

www.itp-consulting.com

2

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

Page 3: Enhancement Framework_BADI Development

www.itp-consulting.com

3

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

.

Page 4: Enhancement Framework_BADI Development

www.itp-consulting.com

4

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

Page 5: Enhancement Framework_BADI Development

www.itp-consulting.com

5

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.

Page 6: Enhancement Framework_BADI Development

www.itp-consulting.com

6

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.

Page 7: Enhancement Framework_BADI Development

www.itp-consulting.com

7

What is a BADI?

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.

Page 8: Enhancement Framework_BADI Development

www.itp-consulting.com

8

What is a BADI? (Definition)

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

Page 9: Enhancement Framework_BADI Development

www.itp-consulting.com

9

What is a BADI? (implementation)

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

Page 10: Enhancement Framework_BADI Development

www.itp-consulting.com

10

What is a BADI? 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

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)

Page 11: Enhancement Framework_BADI Development

www.itp-consulting.com

11

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:

.

Page 12: Enhancement Framework_BADI Development

www.itp-consulting.com

12

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.

Page 13: Enhancement Framework_BADI Development

www.itp-consulting.com

13

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

Page 14: Enhancement Framework_BADI Development

www.itp-consulting.com

14

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

Page 15: Enhancement Framework_BADI Development

www.itp-consulting.com

15

Implement a BADI (Classic) A pop-up screen appears, as shown. Enter the name of the BADI

involved and press the Enter button.

Page 16: Enhancement Framework_BADI Development

www.itp-consulting.com

16

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.

Page 17: Enhancement Framework_BADI Development

www.itp-consulting.com

17

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

Page 18: Enhancement Framework_BADI Development

www.itp-consulting.com

18

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

Page 19: Enhancement Framework_BADI Development

www.itp-consulting.com

19

Implement a BADI (Classic)

Step 2: Activate the BADI!

Page 20: Enhancement Framework_BADI Development

www.itp-consulting.com

20

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.

Page 21: Enhancement Framework_BADI Development

www.itp-consulting.com

21

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.

Page 22: Enhancement Framework_BADI Development

www.itp-consulting.com

22

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

Page 23: Enhancement Framework_BADI Development

www.itp-consulting.com

23

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

Page 24: Enhancement Framework_BADI Development

www.itp-consulting.com

24

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!

Page 25: Enhancement Framework_BADI Development

www.itp-consulting.com

25

Further Information Help Portal

http://help.sap.com Documentation SAP Netweaver (04s) Application Platform ABAP technology ABAP Workbench Enhancement Framework

SDNhttp://sdn.sap.com

Page 26: Enhancement Framework_BADI Development

www.itp-consulting.com

26

Address Feedback & Questions

from audience

Page 27: Enhancement Framework_BADI Development

www.itp-consulting.com

27

Copyright 2007 , All Rights Reserved No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of IT Partners Inc.. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, and Informix are trademarks or registered trademarks of IBM Corporation. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are

trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only.

IT Partners Inc. assumes no responsibility for errors or omissions in this document. IT Partners Inc. does not warrant the accuracy or completeness of the information, text, graphics, links, or other items contained within this material.

This document is provided without a warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, or non-infringement.

IT Partners Inc. shall have no liability for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. This limitation shall not apply in cases of intent or gross negligence.

The statutory liability for personal injury and defective products is not affected. IT Partners Inc. has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third-party Web pages nor provide any warranty whatsoever relating to third-party Web pages.