Sei sulla pagina 1di 13

Enhancements :

Enhancements are the means by which we add our own/ modify existing functionality to SAP's
standard business applications.
Generally when we try to modify or change the SAP standard Program, it will ask u Access key
which you can get from SAP market place by requesting SAP.
But coming to enhancements, normally dont ask any Access key and can be implement directly.
There are 4 ways of doing enhancements in SAP:
1. User exits
2. Customer exits
3. BADI's
4. Enhancement Frameworks

User exits
These are technically modifications. SAP provides many subroutine(s) with name USEREXIT_ * (i.e
ex: FORM USEREXIT_001)
These are saved in many includes which can be found via SE80 >> Search for Package VMOD.
These are also called as Form exits.
Custom coding can be done in the subroutine. But the main disadvantage of these exits is, It
requires Access key and only SD module supports this kind of enhancements.

Function exits

Customer exits:

Menu Exits
Screen exits

Function exits
Provided by means of FMs (Function modules) .The code for the function module is written
by the developer. You are not writing the code directly in the function module, but in the 'Z'
include that is implemented in the function module.
Ex: open any Function module EXIT_* in se37
It will have a Z include file, just edit the file directly. No Access key required.
Menu Exits
Enhances the menu available in standard SAP program. Developer can add his/her own text
and logic for the menu. Function codes for menu exits all start with "+".
EX: Format: +CUS (additional item in GUI status)

Screen Exits
Used to enhance the screen, add elements in screen etc.
Format: CALL CUSTOMER-SUBSCREEN CUSTSCR2.

BADI's
Business Add-Ins may be simply defined as an object-oriented extension of the SAP
enhancement technique. Multiple implementation for same BADI can be done as BADI
supports encapsulation of data.

Classical are the old ones which you can see and implement thru SE18. Kernel Badi's belong to the
new enhancement frame work. These can be viewed both in SE18 and SE19. The main difference is
that Kernel Badi's belong to an enhancement spot but classical badi's are stand alone Badi's.

Calssical Badi's:
1. SE18

2. Called thru cl_exit_handler

Kernel Badis:
1. SE18/SE19
2. Called thru GET badi and CALL Badi.
3. Execution is faster than the classical Badi.
4. Are always assigned to an enhancement spot.

Enhancement Frameworks:

This is the new kind of enhancement technique provided by SAP. These provides some hooks or
places where custom logic can be coded in the standard program.There are 2 kinds of Enhancement
frameworks:
a) Implicit and
b) Explicit Enhancements

In order to understand the enhancement framework, you need to understand the terms used in
SAP and their hierarchy.

1. Enhancement Spot.
2. Enhancement point/Enhancement Section
3. Enhancement Implementations.
4. Kernel Badi

Spot: is nothing but a container for the points/sections. Assume something like a transport which
holds different objects. The objects that the spot hold will be either a point/section/kernel Badi or a
combination of these.

Points are the actual enhancements. These can be implicit point or explicit point.

Implicit: are always available in any SAP programs (programs/includes/FMs etc). Right click enhancement operations - show implicit enhancements. You have to click on the spiral icon to modify
these implicit enhancements.

Explicit points are those that are provided by SAP. These are defined by the SAP programmer.
Something like a customer exit. The SAP programmer has assigned this to an spot.

Section: Similar to explicit. These are defined by SAP and assigned to a spot. The difference
between explicit point and section is that, when you implement a section, the existing code in the
section by SAP will be replaced by the customers code. In case of EP, both SAPs and customers
code are executed.

Enhancement implementations are the actual implementations that we create inside a point/section.

Find Application class with Exits and Badis for a


Transaction
I know that there are simular codes running about but in some cases the returned values were incorrect.
Due to this fact I decided to create my own report to find Exits and Badis which affect a Transaction. I know that there are
certain transactions where the returned list is still not correct, but the list returned by this report does usually contain a
correct list of Exits that can be user and Badis with standard and customer own implementations.
Two examples for incorrect values returned are IW51 which is in the application class IWOC or CLM1 which is in the
application class CLAIM which is actually correct, although the notification application is assigned to QQM and varios exits
apply to all three application classes.
I would be keen on recieving feedback, if this report helps ease the search, and if it can be improved.
All you need is to enter the transaction code and press F8
This report finds Exits in the application area of the Transaction
This report finds Badis in the application area of the Transaction
This is not an official SAP report but it should not cause any damage:
Goto SE38 and create an executable test report ZZ_EXIT_FIND and insert the coding below:

*&---------------------------------------------------------------------\*
*& Report ZZ_EXIT_FIND

*&

*&---------------------------------------------------------------------\*
*&

*&

*&---------------------------------------------------------------------\*
REPORT ZZ_EXIT_FIND.
*&---------------------------------------------------------------------\*
*& Enter the transaction code that you want to search through in order *
*& to find which Standard SAP User Exits exists.

*& Tables

*&---------------------------------------------------------------------\*
TABLES : tstc, "SAP Transaction Codes
tadir, "Directory of Repository Objects
modsapt, "SAP Enhancements - Short Texts
modact, "Modifications
trdir, "System table TRDIR
tfdir, "Function Module
enlfdir, "Additional Attributes for Function Modules
tstct, "Transaction Code Texts
RSSTCD,
TRKEY.
*&---------------------------------------------------------------------\*
*& Definition of Types
*
*&---------------------------------------------------------------------\*
TYPES: BEGIN OF t_badi_list,
obj_name TYPE sobj_name ,
devclass TYPE devi_class ,
dlvunit TYPE dlvunit,
imp_name TYPE exit_imp ,
packname TYPE devclass ,
dlvunit2 TYPE dlvunit,
text TYPE sxc_attrt-text,
END OF t_badi_list.
TYPES: BEGIN OF t_badi_list2,
obj_name TYPE sobj_name ,
devclass TYPE devi_class ,
dlvunit TYPE dlvunit,
END OF t_badi_list2.
*&---------------------------------------------------------------------\*
*& Data Declaration
*
*&---------------------------------------------------------------------\*

DATA: lt_badi_list TYPE TABLE OF t_badi_list,


lt_badi_list2 TYPE TABLE OF t_badi_list2,
ls_badi_list TYPE t_badi_list OCCURS 0 WITH HEADER LINE,
ls_badi_list2 TYPE t_badi_list2.
RANGES: r_badi FOR tadir-obj_name ,
rt_badi FOR tadir-obj_name .
*&---------------------------------------------------------------------\*
*& Variables
*
*&---------------------------------------------------------------------\*
DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE,
P_TRKEY LIKE TRKEY.
DATA : field1(30),
BADINAME(20),
COUNT TYPE P.
DATA : v_devclass LIKE tadir-devclass,
p_devclass LIKE tadir-devclass,
p_old_langu LIKE sy-langu,
p_mod_langu LIKE sy-langu.
*&---------------------------------------------------------------------\*
*& Selection Screen Parameters
*
*&---------------------------------------------------------------------\*
SELECTION-SCREEN BEGIN OF BLOCK a01 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS : p_tcode LIKE tstc-tcode OBLIGATORY.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK a01.
*&---------------------------------------------------------------------\*
*& Start of report
*
*&---------------------------------------------------------------------\*
START-OF-SELECTION.
* Validate Transaction Code
SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode.
*Find Repository Objects for transaction code
IF sy-subrc EQ 0.

SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR'


AND object = 'PROG'
AND obj_name = tstc-pgmna.
MOVE: tadir-devclass TO v_devclass.
IF sy-subrc NE 0.
* This section is used if a FGR is involved\!
CALL FUNCTION 'RS_ACCESS_PERMISSION'
EXPORTING
global_lock = 'X'
object = p_tcode
object_class = 'TRAN'
mode = 'SHOW'
language_upd_exit = 'RS_TRANSACTION_LANGUAGE_EXIT'
suppress_language_check = space
IMPORTING
new_master_language = p_old_langu
modification_language = p_mod_langu
transport_key = p_trkey
devclass = p_devclass
EXCEPTIONS
canceled_in_corr = 1
OTHERS = 2.
IF SY-SUBRC = 0. " Success
MOVE: p_devclass TO v_devclass.
ELSE. " For the case that nothing is found\!
SELECT SINGLE * FROM trdir WHERE name = tstc-pgmna.
IF trdir-subc EQ 'F'.
SELECT SINGLE * FROM tfdir WHERE pname = tstc-pgmna.

SELECT SINGLE * FROM enlfdir WHERE funcname = tfdir-funcname.


SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR'
AND object = 'FUGR'
AND obj_name = p_devclass.
MOVE: tadir-devclass TO v_devclass.
ENDIF.
ENDIF.
ENDIF.
*Find SAP Modifactions
SELECT * FROM tadir INTO TABLE jtab
WHERE pgmid = 'R3TR'
AND object = 'SMOD'
AND devclass = v_devclass.
SELECT SINGLE * FROM tstct WHERE sprsl EQ sy-langu
AND tcode EQ p_tcode.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
WRITE:/(19) 'Transaction Code - ', 20(20) p_tcode, 45(50) tstct-ttext.
FORMAT COLOR COL_POSITIVE INTENSIFIED ON.
SKIP.
WRITE:/1 'The application area is:', v_devclass.
SKIP.
IF NOT jtab[] IS INITIAL.
WRITE:/(95) sy-uline.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/1 sy-vline, 2 'Exit Name', 21 sy-vline, 22 'Description', 95 sy-

vline.

WRITE:/(95) sy-uline.
LOOP AT jtab.
SELECT SINGLE * FROM modsapt

WHERE sprsl = sy-langu


AND name = jtab-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
WRITE:/1 sy-vline, 2 jtab-obj_name HOTSPOT ON, 21 sy-vline , 22
modsapt-modtext,
95 sy-vline.
ENDLOOP.
WRITE:/(95) sy-uline.
DESCRIBE TABLE jtab.
SKIP.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ 'No of Exits:' , sy-tfill.
SKIP.
WRITE:/(83) sy-uline.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/1 sy-vline, 2 'Badi Name', 22 sy-vline, 23 'Description', 83 syvline.
WRITE:/(83) sy-uline.
* select the BAdI Definitions from the tables sxc_exit and sxc_attr
SELECT t~obj_name t~devclass tc~dlvunit sx~imp_name sat~text
INTO CORRESPONDING FIELDS OF TABLE lt_badi_list
FROM ( ( ( ( tadir AS t
INNER JOIN
tdevc AS tc ON t~devclass = tc~devclass )
INNER JOIN
sxc_exit AS sx ON sx~exit_name = t~obj_name )
INNER JOIN
sxc_attr AS sa ON sx~imp_name = sa~imp_name )
INNER JOIN
sxc_attrt AS sat ON sx~imp_name = sat~imp_name )

WHERE t~pgmid = 'R3TR'


AND t~object = 'SXSD' "means BAdI
AND t~devclass = v_devclass "narrow down seach with
Dev.Class
AND sat~sprsl = sy-langu.
SORT lt_badi_list.
DELETE ADJACENT DUPLICATES FROM lt_badi_list.
* create Ranges
LOOP AT lt_badi_list INTO ls_badi_list .
r_badi-sign = 'I' .
r_badi-option ='EQ' .
r_badi-low = ls_badi_list-imp_name .
r_badi-high = ls_badi_list-imp_name .
APPEND r_badi TO rt_badi .
ENDLOOP.
* select the implementations
SELECT t~obj_name t~devclass tc~dlvunit
INTO CORRESPONDING FIELDS OF TABLE lt_badi_list2
FROM tadir AS t
INNER JOIN
tdevc AS tc ON t~devclass = tc~devclass
FOR ALL ENTRIES IN rt_badi
WHERE t~obj_name = rt_badi-low
AND t~pgmid = 'R3TR'
AND t~object = 'SXCI'.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
WRITE:/(83) sy-uline.
COUNT = '0'.
LOOP AT lt_badi_list INTO ls_badi_list .

WRITE:/1 sy-vline, 2 ls_badi_list-obj_name HOTSPOT ON, 22 sy-vline,


23 ls_badi_list-text, 83 sy-vline.
COUNT = COUNT + 1.
ENDLOOP.
WRITE:/(83) sy-uline.
DESCRIBE TABLE ls_badi_list.
SKIP.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ 'No of BADIs:' , COUNT.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(95) 'No User Exit exists'.
ENDIF.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(95) 'Transaction Code Does Not Exist'.
ENDIF.
*&---------------------------------------------------------------------\*
*& Call SMOD or SE18 to lead the user to the selected exit or badi
*
*&---------------------------------------------------------------------\*
AT LINE-SELECTION.
GET CURSOR FIELD field1.
IF field1(4) EQ 'JTAB'.
SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.
ELSEIF field1(12) EQ 'LS_BADI_LIST'.
CALL FUNCTION 'SXO_BADI_SHOW'
EXPORTING
EXIT_NAME = sy-lisel+1(20)

EXCEPTIONS
ACTION_CANCELED
ACCESS_FAILURE
BADI_NOT_EXIXTING.
ELSE.
ENDIF.