user exits & badi

36
© 2010 StraVis IT Solutions Pvt Ltd. User-Exits

Upload: sandeepyelakanti

Post on 27-Nov-2014

712 views

Category:

Documents


29 download

TRANSCRIPT

Page 1: User Exits & Badi

© 2010 StraVis IT Solutions Pvt Ltd.

User-Exits

Page 2: User Exits & Badi

2 © 2010 StraVis IT Solutions Pvt Ltd.

Overview

If you try to change the SAP

program “SAPMF02K”, you

will be prompted to enter the

access key for that object.

Page 3: User Exits & Badi

3 © 2010 StraVis IT Solutions Pvt Ltd.

Overview

Page 4: User Exits & Badi

4 © 2010 StraVis IT Solutions Pvt Ltd.

User-Exits

Function-Exits

Menu-Exits

Screen-Exits

Page 5: User Exits & Badi

5 © 2010 StraVis IT Solutions Pvt Ltd.

Information on existing User-Exits

Page 6: User Exits & Badi

6 © 2010 StraVis IT Solutions Pvt Ltd.

Function-Exits

*----------------------------------*

* include zxf05u01. *

*----------------------------------*

This INCLUDE program is

where you will write the

customer-specific code.

call customer-function

“001”...

function

exit_sapmf02k_001.

include zxf05u01.

endfunction.

SAP Original Code

“SAPMF02K”

Function Module INCLUDE Program

This INCLUDE program

will not be overwritten

with an SAP upgrade

because it is not SAP

original code.

Page 7: User Exits & Badi

7 © 2010 StraVis IT Solutions Pvt Ltd.

Call Customer-Function Versus Call Function

Both of these CALL

statements refer to

the function module

“EXIT_SAPMF02K_001”.

The CALL CUSTOMER-FUNCTION

statement will only execute the function

module if the module

is activated.

call function ‘EXIT_SAPMF02K_001’

Page 8: User Exits & Badi

8 © 2010 StraVis IT Solutions Pvt Ltd.

Business Case Scenario

When the user updates a vendor record, you want to

insert a record into an update log that contains the

vendor number and name of the updated record.

UPDATE LOGVendor #Vendor name

Page 9: User Exits & Badi

9 © 2010 StraVis IT Solutions Pvt Ltd.

Steps to Coding a Function-Exit

1. Locate Function-Exit(s)

2. Go to Function Module

3. Create INCLUDE Program

4. Code in INCLUDE Program

5. Activate Function-Exit

Page 10: User Exits & Badi

10 © 2010 StraVis IT Solutions Pvt Ltd.

Locate Function-Exit(s)

Page 11: User Exits & Badi

11 © 2010 StraVis IT Solutions Pvt Ltd.

Locate Function-Exit(s)

In program “SAPMF02K”, search

for the string “call customer-

function” in the main program to

find all of the function-exit(s) in

the program.

Page 12: User Exits & Badi

12 © 2010 StraVis IT Solutions Pvt Ltd.

Locate Function-Exit(s)

Double-click anywhere on the

call customer-function “001”

statement to go to that line in

the SAP program.

In program “SAPMF02K”,

there is only one function-exit

at line 83 of “MF02KFEX”.

Page 13: User Exits & Badi

13 © 2010 StraVis IT Solutions Pvt Ltd.

Go to Function Module

Double-click on „001‟ of the

CALL CUSTOMER-FUNCTION

“001” statement in the SAP

program to go to the function

module “EXIT_SAPMF02K_001”.

Page 14: User Exits & Badi

14 © 2010 StraVis IT Solutions Pvt Ltd.

Create INCLUDE Program

Double-click on the INCLUDE

ZXF05U01 statement in the

function module to create the

INCLUDE program.

Page 15: User Exits & Badi

15 © 2010 StraVis IT Solutions Pvt Ltd.

Code in INCLUDE Program

1

2

6

*------------------------------

* INCLUDE ZXF05U01

*------------------------------

if sy-uname = ‟ DANTHON‟.

endif.

Write your code in

this INCLUDE

program.

Page 16: User Exits & Badi

16 © 2010 StraVis IT Solutions Pvt Ltd.

Activating Function-Exit

X

X

PROJECT 1

(can be activated/deactivated)

Enhancement 1

Enhancement

2

Function

Exit

Screen

Exit

Function

Exit

PROJECT 2

(can be activated/deactivated)

Enhancement3

Function

Exit

Page 17: User Exits & Badi

17 © 2010 StraVis IT Solutions Pvt Ltd.

User-Exit Transactions

CMOD

SMOD

Page 18: User Exits & Badi

18 © 2010 StraVis IT Solutions Pvt Ltd.

Transaction CMOD

In transaction CMOD, type in the

name of your project and press the

CREATE pushbutton.

Page 19: User Exits & Badi

19 © 2010 StraVis IT Solutions Pvt Ltd.

Transaction CMOD

Once you SAVE your project, you

can add as many enhancements as

you want by pressing the SAP

enhancements pushbutton.

Page 20: User Exits & Badi

20 © 2010 StraVis IT Solutions Pvt Ltd.

Transaction CMOD

Add the enhancements you want

included in

the project.

Page 21: User Exits & Badi

21 © 2010 StraVis IT Solutions Pvt Ltd.

Transaction CMOD

After saving your project, you need

to ACTIVATE it.

Page 22: User Exits & Badi

22 © 2010 StraVis IT Solutions Pvt Ltd.

Transaction SMOD

With the name of the enhancement, you

can display its components.

Page 23: User Exits & Badi

23 © 2010 StraVis IT Solutions Pvt Ltd.

Transaction SMOD

In the case of enhancement

“SAPMF02K”, there is only one

user-exit – a function-exit using

the function module

“EXIT_SAPMF02K_001”.

Page 24: User Exits & Badi

24 © 2010 StraVis IT Solutions Pvt Ltd.

Summary

Function-Exits

Menu-Exits

Screen-Exits

1. Locate Function-Exit(s)

2. Go to Function Module

3. Create INCLUDE Program

4. Code in INCLUDE Program

5. Activate Function-Exit

Page 25: User Exits & Badi

© 2010 StraVis IT Solutions Pvt Ltd.

Business Add-Ins

Page 26: User Exits & Badi

26 © 2010 StraVis IT Solutions Pvt Ltd.

What is BAdi

• New SAP enhancement technique

• To accommodate user requirements not available / too specific to be included in the SAP

standard Program

• Based on ABAP Objects – It has Interfaces & Methods

• Guaranteed 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

Page 27: User Exits & Badi

27 © 2010 StraVis IT Solutions Pvt Ltd.

BADI vs. User Exit

• In User Exits, an application programmer predefines exit points in a source that allow specific

industry sectors, partners, and customers to attach additional software to standard SAP

source code without having to modify the original object.

• The users of Business Add-Ins can customize the logic they need or use a standard logic if

one is available. They can be inserted into the SAP System to accommodate user

requirements too specific to be included in the standard delivery.

Page 28: User Exits & Badi

28 © 2010 StraVis IT Solutions Pvt Ltd.

BAdi & Customer-Exit

• Though different enhancement technique, BAdi has following distinct features

– Uses Object oriented approach

– Two parts - Definition and its Implementation - definition can either be SAP provided or

user may also create it

– no longer assumes a two-system infrastructure (SAP and customers)

– allows multiple levels of software development (by SAP, partners, and customers, and

as country versions, industry solutions, and the like)

Page 29: User Exits & Badi

29 © 2010 StraVis IT Solutions Pvt Ltd.

BAdi – where to find

• Look for BAdi in IMG and in component hierarchy (using transaction SE18)

• Create own implementation of the add-in (complete coding for Methods) and activate

• Enhancement's active components are called at runtime.

Page 30: User Exits & Badi

30 © 2010 StraVis IT Solutions Pvt Ltd.

BAdi Definition (SE18)

• To include Business Add-Ins in the program

– Define an interface for the enhancement in the SAP menu under Tools-> ABAP

Workbench -> Utilities -> Business Add-Ins -> Definition (transaction SE18)

– Call the interface at the appropriate point in application program

– Customers can then select the add-in and implement it according to their needs

Page 31: User Exits & Badi

31 © 2010 StraVis IT Solutions Pvt Ltd.

BAdi Implementation (SE19)

• ABAP Workbench ->Utilities -> Business Add-Ins -> Implementation (transaction SE19)

• Find the suitable Business Add-Ins present in system (Use IMG or Component hierarchy)

• Use Add-Ins Documentation to understand functionality & to decide

• Implement the Add-Ins

– a class is created with the same interface

– Finalize coding for the method

• Implementations are discrete transport objects and lie within the namespace of the person

or organization implementing them

Page 32: User Exits & Badi

32 © 2010 StraVis IT Solutions Pvt Ltd.

Filter dependent BADI

If enhancement needs to be different based on some parameter (e.g. country-specific or company-

code specific), separate implementation of the same Add-In can be created and activated.

At run time, the specific implementation will be executed

Possible through filter dependent BADI.

What qualifies as a filter?

A Data element Underlying domain may contain a maximum of 30 characters and must be of

Character type

The data element must Either have a search help with a search help parameter of the same type

as the data element and this parameter must serve as both the import and export parameter or

the element's domain must have fixed domain values or a value table containing a column with

the same type as the data element

Before implementing filter objects to a BADI. We need to deactivate all the implementation for

that BADI..

Page 33: User Exits & Badi

33 © 2010 StraVis IT Solutions Pvt Ltd.

Contd..

Click on the F4 on the FILTER TYPE field name and enter some search criteria to find a

relevant data element.

Page 34: User Exits & Badi

34 © 2010 StraVis IT Solutions Pvt Ltd.

Contd..

• Click on the save button and active the BADI definition.

• Now to ensure that the interface parameters have been adjusted by the system click on the

interface tab and then double click on any method to see the list of parameters.

Page 35: User Exits & Badi

35 © 2010 StraVis IT Solutions Pvt Ltd.

Contd..

Select the menu IMPLEMENTATION -> DISPLAY.

• The system will display all the implementation if it has more than one implementation.

• Select the first implementation and click on the continue button

• You will notice that now the implementation is capable of adding filters for the user names. You

can click on the INSERT ROW button to add any new filters.

• And as you can see from the screen shot below the new parameter list is automatically available in

the implementation part.

• Now lets use this filter type and make changes to the program.

• Click on the save and activate the method.

• Return to the initial screen of the implementation and define a filter value by clicking on the

INSERT ROW button under the filter section. The filter value acts like a condition. Only if, during

the runtime the filter value matches the method will get executed. Once done click on save and

activate the implementation.

Page 36: User Exits & Badi

36 © 2010 StraVis IT Solutions Pvt Ltd.

Thank you