Sie sind auf Seite 1von 15

ABAP ENHANCEMENTS

SAP delivers a broad range of business functions within its R/3 application suite. You may find that the standard applications do not offer some of the functionality you need. The R/3 enchancement concept allows you to add your own functionality to SAP's standard business applications.

SAP creates customer exits for specific programs, screens and menus within standard R/3 applications. These exits do not contain any functionality. Instead, the customer exits act as hooks. You can hang your own add-on functionality onto these hooks. Purpose of the Enhancement Concept

With the ABAP/4 Development Workbench, SAP's client-server development environment, you can create add-ons or entire applications. Before the enhancement concept existed, customers who wanted to add their own specific functions to SAP software had to modify the standard SAP programs. Modifying 1.Modifying SAP's standard software code holds can at least lead two to dangers: errors

When a customer changes the source code of a standard program, these changes can have unwanted results within other parts of the application. Once a customer has begun 'reconstructing' a standard program, SAP can no longer guarantee that this customer's system will run without serious errors.

2.Modifications

mean

more

work

during

software

upgrades

Customers of standard software packages often want to take advantage of software upgrades or new releases. Customers who have modified the software of their current release must save these modifications and reenter them into the new software after each upgrade or release change. Depending on the number and scope of modifications, this reentry process may make it difficult or even impossible to take advantage of new software releases. The enhancement concept offers a better alternative to the problem-ridden modification approach. Reason for Using Exits

If you want to extend the functionality of your R/3 System, you should take advantage of the exits available within the standard R/3 applications. There are two main reasons why you should use exits rather than modifying SAP software. Add-ons that are attached to exits have the advantage that they: 1.Do not affect standard SAP source code When you add new functionality to your R/3 System using SAP's exits, you do not change the source code of standard SAP programs. The code and screens you create are encapsulated as separate objects. These customer objects are linked to standard applications, but they exist apart from SAP's standard software package.

2.Do not affect software upgrades When you add new functions using SAP's exits, the objects you develop are customer objects. Customer objects adhere to strict naming conventions. When the time comes to upgrade a software release, the special names of customer objects ensure that they will not be affected by either changes or additions within the standard software package. As a result, you do not need to save and then reenter add-ons attached to exits. Customer exits are not available for all programs and screens within the R/3 standard applications. You can only use exits if they already exist within the SAP R/3 System. Locating Applications that Have Exits explains how to find applications with predefined exits.

If no user exit is available in an area where you want to add your own functionality, you can request that SAP develop an exit. You can make this request via the Online Service System (OSS). Types of Exits

There are four basic types of customer exits. Each of these exits is a hook that you can hang your add-ons onto. Menu exits Add items to the pulldown menus in standard R/3 applications. You can use these menu items, for example, to call up your own screens or to trigger entire add-on applications. SAP creates menu exits by defining special menu items in the Menu Painter. These special entries have function codes that begin with + (plus sign). You specify the menu item's text when activating the item within an add-on project.

Screen exits Add fields to the screens within R/3 applications. SAP creates screen exits by placing special subscreen areas within a standard R/3 screen and calling a customer subscreen from within the standard dynpro's flow logic. Function module exits Add functionality to R/3 applications. Function module exits play a role in both menu and screen exits. When you add a new menu item to a standard pulldown menu, for example, you can use a function module exits to define the actions that should take place once

your menu is activated. Function module exits also control the data flow between standard programs and the fields created within dynpro exits. SAP application developers create function exits by preparing calls to customer functions within standard R/3 programs. These calls have the following syntax: CALL CUSTOMER-FUNCTION '001'.

Keyword exits Add documentation to the data elements of key words defined in the ABAP/4 Dictionary. The system displays this documentation whenever a user presses F1 to get online help for a screen field. Unlike the other exits listed above, documentation exits do not require that SAP make any special preparations. Creating an Add-on Project

To take advantage of the exits available within standard R/3 applications, you need to create an add-on project. This project lets you organize the enhancement packages and exits you want to use. The add-on project also allows you to hang add-on functionality onto the exit hooks contained with SAP enhancements. Managing an Add-on Project

An add-on project contains a series of exits and the add-ons, such as menu entries or function modules, that you develop to hook onto these exits. To create an add-on project from within the ABAP/4 Development Workbench menu, choose Utilities Enhancements Project management.

Before you begin defining a project, you need to decide which application, application component, or specific standard transaction you would like to add your own functionality to. Give your project a name that indicates the type of functions it contains or shows which transactions are affected. It might be useful to agree upon a company-wide naming convention for enhancement projects.

There are two factors you need to keep in mind when you create an add-on project. First, you can include an SAP enhancement package and the customer exits it contains in one project only. The same SAP enhancement may not appear in two different customer projects.

Second, in order to make your add-ons, such as menu items or screen fields, appear in standard R/3 applications, you must activate your add-on project. When you activate a project, all of the add-ons created within this project are turned on. For this reason, you should ensure that the exits

you include in your project contain functions that can be activated simultaneously. It is not possible to activate specific exits only. After 1. 2. 3. you have specified the name of your Choose project by the new project, proceed as follows: Create. descriptive text. icon.

Describe

the

nature Choose

of

the

providing

a short SAVE

The system prompts you to assign a change task. This assignment allows you to transport the project and its components into a productive system once you have completed it. 4. Specify which SAP enhancements packages you want to include in your project by choosing SAP enhancements. 5. Enter the names of all the SAP enhancements in the spaces provided. You should choose enhancements packages which logically belong together. If you are planning to use several enhancements that deal with Materials Management modules, for example, you can include each of these enhancements in the same project. If you are working on enhancements that deal with different applications, or if the enhancements are not logically related, you should include these enhancements in separate projects. Once you have identified the SAP enhancements to include in your project, you can begin adding your own functionality to the exits offered in the enhancements. To display the individual components of the SAP enhancements, return to the main screen of the Project Management transaction and choose Enhancement components. The system shows you all of the exits included in each of the enhancements assigned to your project.

To take advantage of the exits available within standard R/3 applications, you need to create an add-on project. This project lets you organize the enhancement packages and exits you want to use. The add-on project also allows you to hang add-on functionality onto the exit hooks contained with SAP enhancements. Managing an Add-on Project

An add-on project contains a series of exits and the add-ons, such as menu entries or function modules, that you develop to hook onto these exits. To create an add-on project from within the ABAP/4 Development Workbench menu, choose Utilities Enhancements Project management.

Before you begin defining a project, you need to decide which application, application component, or specific standard transaction you would like to add your own functionality to. Give your project a name that indicates the type of functions it contains or shows which transactions are affected. It might be useful to agree upon a company-wide naming convention

for

enhancement

projects.

There are two factors you need to keep in mind when you create an add-on project. First, you can include an SAP enhancement package and the customer exits it contains in one project only. The same SAP enhancement may not appear in two different customer projects.

Second, in order to make your add-ons, such as menu items or screen fields, appear in standard R/3 applications, you must activate your add-on project. When you activate a project, all of the add-ons created within this project are turned on. For this reason, you should ensure that the exits you include in your project contain functions that can be activated simultaneously. It is not possible to activate specific exits only.

After 1. 2. 3.

you

have specified the

name of your Choose project by the

new project, proceed as follows: Create. descriptive text. icon.

Describe

the

nature Choose

of

the

providing

a short SAVE

The system prompts you to assign a change task. This assignment allows you to transport the project and its components into a productive system once you have completed it. 4. Specify which SAP enhancements packages you want to include in your project by choosing SAP enhancements. 5. Enter the names of all the SAP enhancements in the spaces provided. You should choose enhancements packages which logically belong together. If you are planning to use several enhancements that deal with Materials Management modules, for example, you can include each of these enhancements in the same project. If you are working on enhancements that deal with different applications, or if the enhancements are not logically related, you should include these enhancements in separate projects. Once you have identified the SAP enhancements to include in your project, you can begin adding your own functionality to the exits offered in the enhancements. To display the individual components of the SAP enhancements, return to the main screen of the Project Management transaction and choose Enhancement components. The system shows you all of the exits included in each of the enhancements assigned to your project. Activating and Deactivating a Project

After you have attached all add-on functionality to the exits in your project, you need to activate the project. Activating a project turns on all your add-ons. You also need to activate your project after you have transported it from a development system into a productive system.

When you activate your project, the system turns on all the add-ons contained within the project. You cannot activate certain add-ons separately. The activate an add-on project, proceed as follows: 1. 2. The Enter the Choose confirms Project Management Activate the project was transaction. project. activated.

system

that

You can now call up a standard SAP transaction that contains an exit you used in your add-on project. Your add-on functionally should appear.

If you need to make changes to any of your add-ons, you must first deactivate the project that contains that add-on. Deactivating a project turns off all of that project's add-ons. To deactivate an add-on project, proceed as follows: 1. 2. The Enter the Choose confirms Project Management Deactivate the project was transaction. project. deactivated.

system

that

Once the project is turned off, you can make changes to the project's add-ons or build new functionality to hook on to the other exits in the project.

Transporting Add-on Projects To take advantage of the exits in the R/3 System, you must create an add-on project. This project contains at least one SAP enhancement package and all the user exits assigned to this package. Your add-on project also holds the add-on functionality you create to hang onto the exit hooks.

When you first create an add-on project, you must assign the project to a change task. You also need to allocate a change task number for every add-on component you develop, such as include programs, subscreens, and menu texts. You can use the same change task number for all your project components. If your project is spread out over more than one change task, you should assign these tasks to the same transport request.

Once you have completed your project, release your change tasks. As a final step, release the transport request that contains all the change tasks for your project. The system will export your add-on project and coordinate its import into a consolidation or productive system. You must then ensure that your add-on project is active.

Using

Field

Exits

Field exits allow you to create your own programming logic for any data element in the Dictionary. You can use this logic to carry out checks, conversions, or business-related processing for any screen field.

The data element BBBNR identifies a company's international location number. You might want to set up your R/3 System so that all international location numbers are larger than 100. The field exit concept lets you create a special function module that contains this logic.

You assign the special function module to the data element BBBNR. You then assign the module to any programs and screens in which users can add new international location numbers. When you activate your field exit, the system automatically triggers your special routine whenever a user enters a company location number. To create your own logic for a particular data element, proceed as follows:

1. Enter the Project management transaction by choosing Utilities Enhancements Project management from the ABAP/4 Development Workbench menu. 2. Choose Text enhancements Field exits. 3. Choose Field exit Create. 4. Enter the name of data element. 5. Choose Continue. The system takes you into the Function Library and suggests a name for your function module (FIELD_EXIT_BBBNR). You should use this name. 6. Create the source code and, if needed, global data for your function module. 7. Activate the function module. After you have created the processing logic for your field exit, you must assign the exit to one or more programs and screens. This assignment tells the system which screens to trigger your function module on. If your processing logic checks naming conventions for a certain field, for example, you might want to trigger the field exit module only on screens where new data can be written to the database. If another screen allows you to display data only, then you can leave out the special function module call. To assign your field exit module to one or more screens, proceed as follows: 1. Select the field exit.

2.ChooseAssignprog./screen.

3. 4.

Enter

the

name

of

the program Choose

and

the

screen

number. Save.

For some fields, you might want to trigger a different processing logic on different screens. You can trigger screen-specific logic by allocating a field exit identifier when you make your screen assignments. A field exit identifier can be any number or letter. The field exit identifier tells the system to trigger the function module that has this identifier in its name.

You create a field exit for the data element BBBNR. You make the following exit and screen assignments: Field 1 2 exit SAPMI0IA SAPMI0IA Program Screen 2300 3450

If a user makes an entry into the BBBNR-related field in screen 2300, the system triggers the function module called FIELD_EXIT_BBBNR_1. If the user makes the same entry in screen 3450, the system triggers the function FIELD_EXIT_BBBNR_2. After you have created one or more function modules and assigned them to programs and screens, you need to activate the field exit. Choose Field exit Activate. The system will trigger the processing logic in your function modules according to the screen assignments you made.

SAP USER EXITS AND ENHANCEMENT

USEREXIT

Userxits allow us to add our own functionality to SAP standard program without modifying it . These are implemented in the form of subroutines and hence are also known as FORM EXITs. The userexits are generally collected in includes and attached to the standard program by the SAP. All Userexits start with the word USEREXIT_...

FORM USEREXIT_.. z.. ENDFORM.

The problem lies in finding the correct userexit and how to find it if one exists for the purpose. Once the correct userexit is found the necessary customer code is inserted in the customer include starting with the z.. in the form routine.

e.g. USEREXIT_SAVE_DOCUMENT_PREPARE

Certain application like SD still provide this form ofenhancement using userexit but this practice is no longer being followed for newer extensions instead they are using EXITs which come bundeled in enhancement packages . Neverthiless existing USEREXITS will be supported by SAP an all the newer versions of SAP.

HOW TO FIND USEREXITS

Userexits can be found in number of ways: 1) To find userexits in SD module ,goto object navigator(SE80) and select development class from the list and enter VMOD in it. All of the userexits in SD are contained in the development class VMOD. Press enter and you will find all the includes which contain userexits in SD for different functions like PRICING, ORDER PROCESSING etc. Select the userexit according to the requirement and read the comment inserted in it and start coding .

Some examples of userexits in SD(SALES & DISTRIBUTION ) are:

1)ADDING OF NEW FIELDS IN PRICING In Pricing in SD the fields on the basis of which pricing is done are derived from the FIELD CATALOG which is a structure KOMG .This structure is used to transfer transaction data to the pricing procedure in SD and is also known as communication structure.This structure KOMG consists of two tables KOMK for Header related fields and KOMP for item related fields. The fields which are not in either of the two tables KOMK and KOMP cannot be used in pricing .Sometimes a need arises when the pricing is to be based on some other criteria which is not present in the form of fields in either of the two tables. This problem can be solved by using USEREXITS which are provided for pricing in SD. Pricing takes place both when the SALES ORDER( Transaction VA01) is created as well as when INVOICING ( Transaction VF01) is done.Hence SAP provides 2 userexits ,one for sales order processing which is

USEREXIT_PRICING_PREPARE_TKOMP or USEREXIT_PRICING_PREPARE_TKOMK Depending upon which table (KOMK or KOMP) the new fields were inserted we use either of the above two userexits.Theseuserexits are found in include MV45AFZZ of the standard SAP sales order creation program SAPMV45A.

In the case of userexit which will be called when invoicing is done ,these

are provided in the include RY60AFZZ which is in the standard SAP program SAPMV45A. The name of the userexits are same. i.e USEREXIT_PRICING_PREPARE_TKOMP or USEREXIT_PRICING_PREPARE_TKOMK

These userexits are used for passing the data from the communication structure to the pricing procedure, for this we have to fill the newely created field in the communication structure KOMG for this we fill the code in the above userexit using the MOVE statement after the data that has to be passed is taken from the database table by using the SELECT statement. The actual structure which is visible in these userexits and which is to be filled for that particular field is TKOMP or TKOMK.

Before the coding for these userexits is done ,it is necessary to create a new field in either of the two tables KOMK or KOMP .For this purpose includes are provided in each of them . To create the field in header data(KOMK) the include provided is KOMKAZ and to create the field in item data(KOMP) the include provided is KOMPAZ.

One possible example for the need of creating new fields can be e.g. Frieght to be based upon transportation zone ,for this no field is available in field catalog and hence it can be created in KOMK and then above userexits can be used to fill the transportation data to it.

2)The other method of finding userexit is to find the word USEREXIT in the associated program of the transaction for which we want to determine userexit using SE38. 3)The other method of finding userexits is to find the include in case of SD/MM applications where the userexits are located ,this can be found in the SAP reference IMG generally in the subfolder under SYSTEM MODIFICATION.

Some other examples of userexits in SD are:

USEREXIT_NUMBER_RANGE

This userexit is used to assign a different internal document number to the sales order(VA01) when it is created depending on some criteria like a different SALES ORGANIZAION(VKORG) .

USEREXIT_SAVE_DOCUMENT_PREPARE This userexit is used to insert the ABAP code which will be called when the document (sales order VA01) is just about to be saved.Thisuserexit is used generally for custom checks on different fields , to display some information before the order will be saved or for making changes to certain fields before the sales order will be saved.

Exits & Enhancements There are mainly six types of EXITs in sap which have been collected in the form of enhancement packages and attached to standard code in SAP. These are different from USEREXIT in the way that they are implemented in the form of FUNCTIONs while in USEREXITS we use form routines for their implementation. These are also sometimes known as function exits . These start from the word EXIT_ followed by the program name and then followed by a three digit number.

e.g. EXIT_SAPMV45A_002 This exit is found in SD in enhancement V45A0002.

TYPES OF EXITS

1)MENU EXITS 2)FUNCTION EXITS 3)TABLE EXITS 4)SCREEN EXITS 5)KEYWORD EXITS 6)FIELD EXITS

We use SAP transactions CMOD and SMOD to manage exits. Before implementing an exit , it is required to create the project by using CMOD selecting the enhancement e.g. V45A0002 and selecting the component (one which fulfills our need) i.e the exit which will be implemented in SMOD and after coding has been done the project has to be activated. An exit can be coded only once.

FUNCTION EXITS These are used to add functionality through ABAP code . These start from the word EXIT_programname_NNN ending in a 3 digit number. No access code is required to implement any tupe of exit including function exits. The function exits are called from the standard SAP program in the form of ABAP statement CALL CUSTOMER-FUNCTION 'NNN'

This is in contrast to USEREXITs where PERFORM statement is used to call the required userexit. To implement the FUNCTION EXITs first of all the project is created and a suitable enhancement package is selected and from its compnents the function exit to be implemented is selected and on double clicking it the exit code will appear in ABAP EDITOR(se38) where a Z include will be found and the customer code should be entered in this include. e.g. ADDING A DEFAULT SOLD-TO-PARTY in Sales Order Creation To show a default sold-to-party in this field when the user creates a sales order (VA01) we can use a function exit .This function exit is located in enhancement no V45A0002 . Before we can choose the exit we have to create a project in CMOD after that enter V45A0002 in the enhancement field and click on the components . In the components you will see the exit EXIT_SAPMV45A_002 . This exit is used for our purpose.

Double clicking on this exit will takes us to function builder (SE37) . This function exit has one exporting parameters and two importing parameters, we are interested in exporting parameter which is E_KUNNR of type KNA1-KUNNR i.e if we move the desired customer name to this structure(E_KUNNR) it will be shown in the field as the default value when we create the sales order. This function also contains a customer include ZXVVA04 . This include will be used to write our custom code . Double clicking on this include and it will prompt us that this include does not exists do you want to create this object ,select yes and the include will be created .In this include we can write our own code that will fill the field E_KUNNR. e.g. E_KUNNR = 301.

Activate the include and Activate the project. Now when ever the SALES ORDER will be created , sold-toparty field will come up with a predefined customer . FIELD EXITS The field exits are managed,created,activated through program RSMODPRF. The field exit is associated with a data element existing in ABAP dictionary and hence to the screen field using that data element. The format of field exit is :

FIELD_EXIT_dataelement_A-Z or 0-9 If a particular screen and program name is not specified than the field exit will effect all the screens containing that data element. The function module associated with field exit shows two parameters INPUT and OUTPUT. Input parameter contains the data passed to the field exit when the field exit was invoked by the R/3 , We can write our own code to change the output parameter depending upon our requirements. Before the field exit can have any effect the system profile parameter ABAP/FIELDEXIT in all the application servers should be set to YES

ABAP/FIELDEXIT = YES.

Das könnte Ihnen auch gefallen