Você está na página 1de 22

Changes to SAP standard - Customizing (fine tune/set up std SAP) - Personalization Minor changes (cosmetic (look-and-feel)) (eg adapt

user menu, create variants, enhance data elements (change field/help texts) (CMOD)) - Modifications Changes directly to the std SAP code (at unassigned points) Via Modification Assistant (Delete, Undo, Replace, New button) all changes are logged. Supported in system upgrades. Object key is needed. (are not switchable by the switch framework and more upgrade effort than Enhancement Framework) (try to avoid) - Customer Developments Develop additional reports, programs, transactions Enhancing Tables/Structures (using Append Structure & Customizing Includes) - Enhancements Changes to SAP (at predefined points) Enhancements: < SAP 4.6: customer exits (function module exits (user exits), menu exits and screen exits) (SMOD, CMOD) >= SAP 4.6: customer exits were migrated to Classic BAdIs (through SMOD) and Business Transaction Events (enhancement technique developed for FI/CO) >= SAP 7.0: Enhancement Framework (new enhancement concept) -> New BAdIs (much faster (40 600 times) than classic BAdIs) BAdI is a method of a class or interface Enhancement implementations: - Begin/end of forms and function modules -> implicit enhancements (source code plug-in) - Enhancement point (add functionality) and sections (change) -> explicit enhancements (are also types of enhancement spots) - Enhancement spots (New BAdI); used to change std. SAP methods -> explicit enhancements (copy ES to new enhancement and badi implementation (also create new class (impl.) / interface (def.))) (object plug-in) Find all calls of the classic BAdI by GET_INSTANCE and reprogram the BAdI call using the new commands GET BADIand CALL BADI. http://help.sap.com/saphelp_nw04s/helpdata/en/91/f1e540f8648431e10000000a1550b0/content.htm

Enhancement Framework: (via Enhancement Builder) The Enhancement Framework offers new possibilities to extend the SAP Standard instead of modifying it: Source Code PlugIns Function Group Enhancements Class Enhancements New BAdIs (object PugIns) Code contains enhancement options. These are predefined points were you can enhance the std functionality. (developed in ABAP Objects (Definition and Implementation part)) - Implicit enhancements (need only Implementation part) * Source code enhancements - Predefined points in code (eg start/end of forms and functions) * Parameter interface enhancements - Parameter interfaces of function modules - Attributes and parameter interfaces of global classes - Explicit enhancements (define Definition and Implementation part) - New BAdIs (= kernel based BAdIs) - Explicit source code points (add code) or sections (replace codes) In ABAP programs, you can select either a position or a program section as an explicit enhancement option. Source code plug-ins for an enhancement are either entered at such a position or they replace the selected section. An explicit enhancement option of an ABAP program is part of the program. It is thus assigned to the package of the program and not necessarily to the package of the enhancement spot to which it belongs. To mark a position/section in a program as an explicit enhancement option, use: ENHANCEMENT-POINT enh_id SPOTS spot1 spot2 ... or ENHANCEMENT-SECTION enh_id SPOTS spot1 spot2 ... ... END-ENHANCEMENT-SECTION. BAdI (new and classic) have a pre-defined interface (SE18?) (implicit enhancement point has no pre-defined interface) Implicit enhancements are already known in the system (they are already defined) Explicit enhancements should be defined (thru enhancement spots). The implementation of enhancements goes via enhancement implementations. Enhancement options are enhanced by: - Implicit enhancements - Predefined points in code -> source code plug-ins - Parameter interfaces of function modules -> parameters - Attributes and parameter interfaces of global classes -> attributes and/or parameters - Explicit enhancements - New BAdIs -> object plug-ins - Explicit source code points or sections -> source code plug-ins SE18 Enhancement Definition Only for explicit enhancements (New BAdIs) and Classic BAdIs. Not possible to insert new classic BAdI definitions (only change existing ones)

Note: To see examples: double-click on Example Implementation Clasee (Interface tab) then double-click on the required method. SE19 Enhancement Implementation For implicit/explicit enhancements and Classic BAdIs. (creates implementation of an existing defined BAdI) It is possible to create a new implementation of an existing classic BAdI. (See for an example document REDUCE (under SAP/IDocs/Change Pointers)). On delete an implementation, the coding will be deleted and deactivation will be executed, automatically. ??? BADI SAP Business Add-Ins (BAdIs) are one of the most important technologies used to adapt SAP software to specific requirements. BAdIs were introduced with Release 4.6 and replace function module exits. This technology is not limited to SAP applications. BAdI calls can be integrated in customer applications. These can then be enhanced by other customer applications. In the various SAP applications, BAdI calls are implemented at places where enhancements are appropriate. In the SAP ERP system, there were already approximately 5,000 BAdIs before Release 7.0. Based on ABAP Objects. - In the definition, you create an enhancement that is called from the application code (SE18) Contains BAdIs interface - In the implementation, you save the code for the functions for the enhancement (SE19) SE18: (Defines interface (for explicit enhancement implementation (New BAdI) and Classic BAdI)) In the application code the instance variable is typed according to the defined interface. You can create several implementations for each add-in definition. There are two main types of BADI definitions: - Multiple use - that is, there can be several active implementations - Filter-dependent - that is, you apply a filter value to each method called (for example, a country). A different (active) implementation is then called for each value. Possible filter values are characterized by the filter type. NEW BADI Enter Enhancement Spot or New BAdI Name (= enhancement spot element definition) (-> starts Enhancement Spot Editor) Classic BADI Enter Classic BAdI Name (-> starts Classic BAdI Builder (with option BAdI migration)) Creation of a classic BAdI is no longer supported (New button will always create a new BAdI). SE19: (Defines implementation (for enhancement implementations and Classic BAdI)) NEW BADI Change/Display: enter Enhancement Implementation (of new BAdI or implicit enhancement).

Create: enter Enhancement Spot (only for explicit enhancements). Enhancement spots manage explicit enhancement implementations. You can create several implementations for each business add-in definition. Note: You can not create (only change) an implicit enhancement here; you should do that (create) in the code (See document 'Create Enhancement Implementation'). Classic BADI Change/Display: enter Implementation of classic BAdI. Create: enter BAdI Name (definition). An implementation is created with reference to a business add-in definition. You can create several implementations for each business add-in definition. SE20: ((combines SE18 and) SE19??) Since Enhancement Framework (Not suited for Classic BAdI) SE84 ABAP Repository Information System. (includes Enhancement Builder) BAdI (one definition) -> One or more Enhancement Implementations -> One or more Enhancement Implementation Elements (expl enh) (EIE can also be an impl enh, enh point/section) New BAdI Interface with defined methods How to find enhancements? (SE84) * Implicit enhancements, Enhancement Points/Sections 1) Since a source code plug-in (= enhancement implementation) is stored in an include starting with a Z: Via SE38 Start program: RPR_ABAP_SOURCE_SCAN - Program Name: Z* - Find String: ENHANCEMENT (if source code starts with Z -> implicit enhancement) Source code plug-ins (includes) are possible (at predefined places): 1) Implicit enhancement implementations In ABAP programs, implicit enhancement options are predefined at the following places: - At the end of an include. There are some restrictions, for example, not at the end of a method include. - At the end of a PUBLIC-, PROTECTED-, PRIVATE-SECTION of a class. - At the end of the implementation part of a class (before the ENDCLASS, which belongs to CLASS IMPLEMENTATION). - At the end of an interface definition (before the ENDINTERFACE). - At the end of a structure definition (before TYPES END OF, DATA END OF, CONSTANTS END OF, and STATICS END OF). - At the beginning and at the end of a procedure (FORM, FUNCTION, METHOD). That is, after

commands FORM, FUNCTION, and METHOD, and before statements ENDFORM, ENDFUNCTION, and ENDMETHOD. - At the end of the CHANGING-, IMPORTING-, EXPORTING-parameter list of a method. These enhancement options are located in the middle of a statement. 2) Explicit enhancement implementations Are defined by ENHANCEMENT-POINT or ENHANCEMENT-SECTION statement. Object plug-ins (methods of an interface) (at predefined places): 1) New BAdI

Naming convention (always global (GV)?): Enhancement option Z(xx)EO_ Enhancement spot Z(xx)ES_ Enhancement implementation Z(xx)EI_ Composite enhancement spot Composite enhancement implementation

Enhancement Option Types are available in a source code: - ENHANCEMENT-POINT can either be static (for example, additional data declaration) or dynamic (for example, additional coding). - ENHANCEMENT-SECTION can either be static (for example, replace an existing data declaration) or dynamic (for example, replace existing coding). - Overlay enhancement overwrite an existing enhancement instead of modifying it. Enhancement points and sections are hooks to which you can assign an enhancement. That is, you can enhance an option by an enhancement. Enhancement Implementation Type: - Static Enhancement Point/Section Additional/Replace data declaration - Dynamic Enhancement Point/Section Additional/Replace source code

SE18

SE19 (Implicit enhancement point)

See code of BADI (SE18) (eg BADI_NUMBER_GET_NEXT) Where Used List button you go to see the code of the BADI call:

Via interface (when double click on method of BADI) + Where Used List button you go to see the code (call + implementation(s)):

Under Program Shows the call of the BAdI Under Classes / Interfaces Shows the implementations Debugging: Breakpoints -> Breakpoints At -> Breakpoint for Method

Class Name Method Name Or Class Name Method Name

: <BAdI name> (eg BADI_MATMAS_ALE_CR) : <method> (eg change_matmas) : <class name> (eg CL_EX_BADI_MATMAS_ALE_CR) : <interface>~<method> (eg if_ex_badi_matmas_ale_cr~change_matmas)

The BAdI name is normally part of the interface name: Interface : IF_EX_BADI_MATMAS_ALE_CR BAdI : BADI_MATMAS_ALE_CR Interface BAdI : IF_BADI_NUMBER_GET_NEXT : BADI_NUMBER_GET_NEXT

Enhancement Framework Enhancement Options BAdI name Enhancement Spot Name Enhancement Implementation Name BAdI X X X X X X Explicit Enh.Point/Section Impl.Enh.

Enhancing Parameter Interfaces


Use
You can enhance the parameter interface of a function module with new, optional formal parameters as enhancement implementation elements. Enhancing by adding new exceptions is not possible. In the context of the enhancement concept, the parameter interface of a function module provides corresponding enhancement options.

Procedure
To implement an enhancement of the interface, use the Function Builder to call the Enhancement Builder: 1. Choose the tab of the parameter type for which you want to insert a formal parameter. 2. Choose Edit Enhancement Operations Enhance Interface for a function module.
A dialog box appears.

3. Select an existing enhancement implementation or create a new one (see Creating an Enhancement Implementation).
This takes you to the enhancement mode of the Function Builder in which the original components of the function module are displayed and cannot be changed.

4. Insert the new formal parameter in the same way as when you create a function module. 5. Save and activate the function module.
The new parameter can now be used at implicit and explicit enhancement options in enhancements to the source code of the function module. This can be done using ABAP source code enhancements.

Enhancements Customer Exits (user exit (function module exit), menu exit, screen exit) Tools -> ABAP Workbench -> Utilities -> Enhancements - Definition (SMOD) - Project Management (CMOD) Shows exits available in standard applications. Classic BADI Tools -> ABAP Workbench -> Utilities -> Business Add-Ins - Definition (SE18) - Implementation (SE19) SE84 SE24 SMOD (to migrate customer exit -> Classic BAdi) Enhancement Points SE20 (and SE18 / SE19) SE84 Implicit enhancement points (eenhancement implementation) Explicit enhancement points (enhancement spot + enhancement implementation) Customer Exits (user exits) CMOD, SMOD SE84 These exits are function modules called by SAP, with fixed input and output parameters, and only containing an INCLUDE ZX... ABAP statement, that the client may create. The exit belongs to exactly one Enhancement (an 8 characters code), that SAP creates using SMOD transaction.

All enhancements SE84 (= SE80 -> Repository Information System) New BADI Via SE18/SE19 Or SE80 (SE84) Represent an explicit Enhancement point. Implementation of BAdIs in the Enhancement Builder Use The BAdI implementations of the enhancement concept are not treated as standalone objects; instead, they are integrated in the overall concept. Consequently, the tools for implementing BAdIs are part of the Enhancement Builder integrated in the ABAP Workbench. Transaction SE19, up to now the only entry point for implementing classic BAdIs, now administers classic and new BAdI implementations. When displaying/changing an existing BAdI implementation, it analyzes

whether the BAdI is a classic or a new one and then switches to the respective tool, which is the enhancement implementation editor for a new BAdI. Implementing classic BAdIs is still supported. Since the classic SE19 transaction represents only a side entry point into the Enhancement Builder, you can also use the Object Navigator (SE80). BADI Based on ABAP Objects New BADI -performance was considerably enhanced. - more flexibility in the conversion of predefined enhancement options through new, orthogonal properties such as contexts and filters. Classic BADI SE80 / SE84

https://websmp230.sap-ag.de/sap(bD1ubCZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=25276 Note 25276 - SAP enhancement concept CMOD: Activation

Business Add-Ins are a new SAP enhancement technique based on ABAP Objects. To find a BADI: We can find a BADI Using CL_EXITHANDLER=>GET_INSTANCE Go to the Transaction, for which we want to find the BADI, Get the Program Name of Corresponding Transaction. (Click on System->Status. Double Click on 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 give you the BADI name for the Transaction. Some BADI can have multiple independent implementations, which is much better for software deployment as several developers can implement the same BADI independently. TRANSACTIONS related to BADI: SE18 - Business Add-in builder SE19 Implementation of BADI SE24 Class/Interface Builder
CUSTOMER EXITS (enhancements) are FUNCTIONS so they are called using CALL FUNCTION (or more exactly CALL CUSTOMER FUNCTION.Customer-exit implemented in one project cannot be implemented in other.

What is the difference between user exit and customer exit? what is meant by customer exit? and what is the difference between user exit and badi?

USER EXITS are FORMS and are called by SAP standard programs using PERFORM. CUSTOMER EXITS are FUNCTIONS so they are called using CALL FUNCTION (or more exactly CALL CUSTOMER FUNCTION). Inside the form (user exit) you can read and change almost any global data from host program. Inside a function (customer exit) you can only acces your import/export/changing/tables parameters. User exits are more flexible because you have more information to use in your code but on the other hand , it is very easy to manipulate erroneously global data and lead the standard program to a dump or even to make database inconsistent. Customer exits are more restrictive but you are sure any change you can make to any parameters will never lead to inconsistency User-exit doesnt have any classification. In customer-exit we have function-module exit , screen exit , menu exit. User exits are Basically designed For SD module. Costomer exits Are available for MM,SD,FI,HR..Basically designed for all modules. diff b/w user exit and badi In user exits we go by general method for enhancements while BADIs we use objects (oops concepts) methods for enhancement UserExits r used for adding additional functionality to the existing SAP standard transactions.Using UserExits we can add additional functionality standard SAP functionality without making any changes to the original code.BADI is a standardized interface for ABAP sources that enables partners and customers to enhance SAP-delivered programs in their namespace.

EXAMPLES Implicit enhancement


ENHANCEMENT <nr> <Implementation name>. ... END-ENHANCEMENT.

Explicit source code point or section


ENHANCEMENT-POINT enh_id SPOTS spot1 spot2 ... [STATIC] [INCLUDE BOUND]. ENHANCEMENT <nr> <Implementation name>. ... END-ENHANCEMENT.

----ENHANCEMENT-SECTION enh_id SPOTS spot1 spot2 ... [STATIC] [INCLUDE BOUND]. ... END-ENHANCEMENT-SECTION.

New BADI
: Calls a BAdI method. For badi, a BAdI reference variable must be specified. For meth, a BAdI method of the corresponding BAdI must be entered directly. The additions assign actual parameters to the formal parameters of the BAdI method, or handle non-class-based exceptions as described in CALL METHOD.

CALL BADI badi->meth

[EXPORTING { {[IMPORTING [CHANGING | [RECEIVING [EXCEPTIONS

p1 = a1 p1 = a1 p1 = a1 r = a [exc1 = [OTHERS

p2 = a2 ...] p2 = a2 ...] p2 = a2 ...]} ] } n1 exc2 = n2 ...] = n_others]].

Or (call method of BAdI) CALL METHOD LF_EXIT->CHANGE_MATMAS

Classic BADI CALL METHOD lr_badi_sd_route->route_determination

Enhance parameter interface


You can enhance the parameter interface of a function module with new, optional formal parameters as enhancement implementation elements. Enhancing by adding new exceptions is not possible. In the context of the enhancement concept, the parameter interface of a function module provides corresponding enhancement options. Procedure To implement an enhancement of the interface, use the Function Builder to call the Enhancement Builder: ... 1. Choose the tab of the parameter type for which you want to insert a formal parameter. 2. Choose Edit Enhancement Operations Enhance Interface for a function module. A dialog box appears. 3. Select an existing enhancement implementation or create a new one (see Creating an Enhancement Implementation). This takes you to the enhancement mode of the Function Builder in which the original components of the function module are displayed and cannot be changed. 4. Insert the new formal parameter in the same way as when you create a function module. 5. Save and activate the function module. The new parameter can now be used at implicit and explicit enhancement options in enhancements to the source code of the function module. This can be done using ABAP source code enhancements.

Explicit Enhancement Options in ABAP Source Codes


Use
In ABAP programs, you can select either a position or a program section as an explicit enhancement option. Source code plug-ins for an enhancement are either entered at such a position or they replace the selected section.
An explicit enhancement option of an ABAP program is part of the program. It is thus assigned to the package of the program and not necessarily to the package of the enhancement spot to which it belongs.

Activities
To mark a position in an ABAP program as an explicit enhancement option, use the following ABAP statement: ENHANCEMENT-POINT enh_id SPOTS spot1 spot2 ... To mark a section in an ABAP program as an explicit enhancement option, use the following ABAP statement: ENHANCEMENT-SECTION enh_id SPOTS spot1 spot2 ... ... END-ENHANCEMENT-SECTION.

Using enh_id, you define the name of the enhancement option or the source code enhancement. After SPOTS, the enhancement option must be assigned to at least one (simple) enhancement spot. For a detailed description of the statements, refer to the ABAP keyword documentation. An enhancement spot for source code enhancements is created using forward navigation from within the ABAP Editor. The statements can either be entered directly or generated by selecting Enhancements Create Enhancement. After the program has been saved, the enhancement option is managed by the Enhancement Builder, and can only be deleted using the function Enhancements Remove Enhancement. During program generation, the source code plug-ins that are in the current system for the assigned enhancement implementations and have the switch status stand-by or on, are included at this position or they replace the selected section.

Ways of Adjusting SAP Standard


BY SAPTRAININGHOUSE, ON DECEMBER 24TH, 2010

The Big Question: Why adjust SAP Standard?


Hey, First tell me why should I change SAP standard in the first place? Isnt it fit to use the way we got it?. Surely, this question would be ringing in your mind since you would have started this tutorial. Unlike other softwares which you would have come across, SAP is not a ready to use software. SAP caters to a variety of businesses and each business though having common business processes on a broad level, have lots of differences from each other. Not even two companies in the same business or industry segment do business in exactly same way. SAP does research on its end to collect the most generic needs of all the industries and puts them in its cross-industry flavor of business solutions. It even dives into specific industry segments to find whats different there and puts the solutions in its industry-specific flavors of business solutions. But still, when SAP continues to put its effort to increase the ease of implementing SAP for customers, there is still a need remaining for customers to do something on their end. This need arises not only due to deficiencies in the delivery from SAP, sometimes also because of various choices given to customers by SAP.

Okay I got it. What are the different levels of changes / adjustments?
Having known why customers need to adjust SAP to fine tune it for themselves, we need to know what are the options or levels of adjustments available? The entire list of available options are broadly classified into following change levels: Personalization: It deals with tweaking of user interface of different SAP applications either on a user group level or on globally to meet the business needs of company on the whole or specific user group or specific user at the lowest level. Some personalization possibilities are for example, setting up defaults for specific screen fields, transaction variants, language/date/time/decimal/printer settings, role based menus, shortcuts, favorites etc. Customizing: You need to setup the SAP applications as per your specific business process e.g. which company codes do you need, what are the different GL accounts in your companys chart of accounts. Basically, its setting up the SAP application with your companys process information. SAP already knows the need of such flexibilities in business process and provides options to set them up without making any code changes. Such kind of adjustment or adaptation of SAP application is known as customizing. All the customizing options of all SAP business applications can be accessed via transaction SPRO. Enhancement: Apart from the providing customizing options which do not need code changes, SAP anticipates certain areas in the SAP standard programs where customer may wish to plugin his code. These situations may arise mainly in two circumstances. First, SAP may not be in position to decide any specific logic for such areas as they are highly dependent on customers needs. Second, SAP may decide a specific logic backed by needs of majority of its customers, but still SAP knows that there would be few customers who would like a different logic. In all such situations, SAP provides options for enhancements using various techniques. Enhancements made by customer are in form of customer developed repository objects (e.g. programs, classes etc. ) which are referred by SAP standard repository objects (e.g. programs, classes etc. ). So, enhancements get plugged into SAP standard repository objects. Customer Development: These are customer developed repository objects which act independently along with SAP standard delivery. These may refer to SAP delivered repository objects. Such customer developments are needed either to fill a gap in the SAP standard delivery or SAP standard delivery follows a different logic than customers needs and at the same time leaves no option for customizing or enhancing the logic. Modification: You may across some situations, where SAP follows a completely different logic in its standard programs in comparison to what your customer needs. On top of this, you see that theres no possibility provided by SAP to adjust the logic also. In these situations, you have two options. First, you can perform a customer development with SAP standard program as template and incorporate your changes. Second, if the first option is not possible or effort is too

high, you resort to the last option of performing a modification of the SAP standard program. This is never a preferred option, since the maintenance of such modifications during SAP version upgrades is quite painful.

Hmm. When do we adopt which level of change?


Follow the following decision making flow chart to analyze your situation and adopt the advised level of change.

http://www.saptraininghouse.com/2010/sap-enhancements/ Concept of Enhancement


Underlying concept behind enhancements in SAP is very simple. In a nutshell, the concept is as follows: SAP delivers a standard version of software comprised of several repository objects. SAP anticipates that this standard version of its software may not be fit for use right away. So, it leaves provision in its repository objects for customers to plugin their developed repository objects. The provisions made by SAP keep looking for the repository objects plugged-in by customers. With these plugged-in objects, the enhanced version of SAP software becomes fit for customers business process. This concept can be visualized as depicted below:

Enhancement Techniques
Depending on the type of repository objects which need to be enhanced and also the influences of the technological advancements, there are various techniques using which enhancement provisions are made in SAP software. Since, SAP ensures downward compatibility during software upgrades, SAP has to keep supporting the enhancement provisions made in past using deprecated enhancement techniques. As a technical consultant, we should be aware of all enhancement techniques. The major enhancement techniques used in various SAP applications are listed below: Enhancing Tables/Structures using Append Structure & Customizing Includes Enhancing Data Elements using Transaction CMOD Customer Exits Function Module Exits, Menu Exits and Screen Exits Business Transaction Events Business Add-Ins (BAdI) Enhancement Framework

Source Code Plug-In - Create an enhancement implementation for an implicit or explicit enhancement option. For more information, see Creating an Enhancement Implementation. An empty source code plug-in is automatically created. It has a unique ID and is displayed in the ABAP Editor below the enhancement option as follows: ENHANCEMENT id. ... ENDENHANCEMENT. - Implement the enhancement between the ENHANCEMENT and ENDENHANCEMENT lines.

Implement Explicit Enhancement Spot that is an Interface (new style BAdI)


Keep in mind that implementing the new style BAdIs (GET/CALL) is Ok but implementing an explicit Enhancement-Point/Section supplied by SAP is not recommended: https://forums.sdn.sap.com/thread.jspa?threadID=872651&messageID=5453372