Abap Enhancements

Embed Size (px)

Citation preview

  • 8/6/2019 Abap Enhancements

    1/15

    ABAP ENHANCEMENTS

    SAP delivers a broad range of business functions within its R/3 application suite. You may findthat 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 businessapplications.

    SAP creates customer exits for specific programs, screens and menus within standard R/3applications. 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, youcan 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 SAPprograms.

    Modifying SAP's software holds at least two dangers:

    1.Modifying standard code can lead to 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 thesemodifications 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 difficultor 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

  • 8/6/2019 Abap Enhancements

    2/15

    If you want to extend the functionality of your R/3 System, you should take advantage of theexits 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 theadvantage that they:

    1.Do not affect standard SAP source code When you add new functionality to your R/3 Systemusing SAP's exits, you do not change the source code of standard SAP programs. The code andscreens 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. Whenthe 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. Asa 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. LocatingApplications 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 canrequest 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 youradd-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 specialentries 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 subscreenfrom 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, forexample, you can use a function module exits to define the actions that should take place once

  • 8/6/2019 Abap Enhancements

    3/15

    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/4Dictionary. 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 anyspecial preparations.

    Creating an Add-on Project

    To take advantage of the exits available within standard R/3 applications, you need to create anadd-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 hookscontained 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 theABAP/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 conventionfor enhancement projects.

    There are two factors you need to keep in mind when you create an add-on project. First, you caninclude 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 theadd-ons created within this project are turned on. For this reason, you should ensure that the exits

  • 8/6/2019 Abap Enhancements

    4/15

    you include in your project contain functions that can be activated simultaneously. It is not possible to activate specific exits o

    After you have specified the name of your new project, proceed as follows:

    1. Choose Create.2. Describe the nature of the project by providing a short descriptive text.3. Choose the SAVE icon.

    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 choosingSAP 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 planningto 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 enhancementsthat 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 addingyour 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 Managementtransaction 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 touse. 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 functionmodules, 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 Projectmanagement.

    Before you begin defining a project, you need to decide which application, applicationcomponent, 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 whichtransactions are affected. It might be useful to agree upon a company-wide naming convention

  • 8/6/2019 Abap Enhancements

    5/15

    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 standardR/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 exitsyou include in your project contain functions that can be activated simultaneously. It is not

    possible to activate specific exits o

    After you have specified the name of your new project, proceed as follows:

    1. Choose Create.2. Describe the nature of the project by providing a short descriptive text.

    3. Choose the SAVE icon.

    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, youcan 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 shouldinclude 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 individualcomponents 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 exitsincluded 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 projectafter you have transported it from a development system into a productive system.

  • 8/6/2019 Abap Enhancements

    6/15

    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. Enter the Project Management transaction.2. Choose Activate project.

    The system confirms that the project was activated.

    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 appe

    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 deactivatean add-on project, proceed as follows:

    1. Enter the Project Management transaction.

    2. Choose Deactivate project.

    The system confirms that the project was deactivated.

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

    Transporting Add-on ProjectsTo 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 alsoneed 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 yourproject 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 youradd-on project and coordinate its import into a consolidation or productive system. You must

    then ensure that your add-on project is active.

  • 8/6/2019 Abap Enhancements

    7/15

    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

    The data element BBBNR identifies a company's international location number. You might wantto 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. Whenyou 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 Projectmanagement 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 yourfunction 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 thedatabase. 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 asfollows:

    1. Select the field exit.

    2.ChooseAssignprog./screen.

  • 8/6/2019 Abap Enhancements

    8/15

    3. Enter the name of the program and the screen number.

    4. Choose 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 screenassignments. A field exit identifier can be any number or letter. The field exit identifier tells thesystem 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 screenassignments:

    Field exit Program Screen

    1 SAPMI0IA 23002 SAPMI0IA 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 screen3450, 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 triggerthe processing logic in your function modules according to the screen assignments you made.

  • 8/6/2019 Abap Enhancements

    9/15

    SAP USER EXITS AND ENHANCEMENT

    USEREXIT

    Userxits allow us to add our own functionality to SAP standard programwithout 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 necessarycustomer 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

  • 8/6/2019 Abap Enhancements

    10/15

  • 8/6/2019 Abap Enhancements

    11/15

    are provided in the include RY60AFZZ which is in the standard SAPprogram SAPMV45A. The name of the userexits are same. i.eUSEREXIT_PRICING_PREPARE_TKOMP orUSEREXIT_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 newelycreated field in the communication structure KOMG for this we fill the code in the above userexit using the

    MOVE statement after the data thathas 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 purposeincludes are provided in each of them .To create the field in header data(KOMK) the include provided is KOMKAZand 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 upontransportation 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 theassociated 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

  • 8/6/2019 Abap Enhancements

    12/15

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

    ORGANIZAION(VKORG) .

    USEREXIT_SAVE_DOCUMENT_PREPAREThis 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 & EnhancementsThere 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 implementedin 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_002This exit is found in SD in enhancement V45A0002.

    TYPES OF EXITS

    1)MENU EXITS2)FUNCTION EXITS3)TABLE EXITS4)SCREEN EXITS5)KEYWORD EXITS6)FIELD EXITS

  • 8/6/2019 Abap Enhancements

    13/15

    We use SAP transactions CMOD and SMOD to manage exits. Before implementing an exit , it is required

    to create the project by using CMODselecting 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 EXITSThese 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 tupeof exit including function exits.

    The function exits are called from the standard SAP program in the formof ABAP statementCALL CUSTOMER-FUNCTION 'NNN'

    This is in contrast to USEREXITs where PERFORM statement is used to callthe 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 locatedin enhancement no V45A0002 . Before we can choose the exit we have tocreate a project in CMOD after that enter V45A0002 in the enhancement field and click on the

    components . In the components you will see theexit EXIT_SAPMV45A_002 . This exit is used for our purpose.

  • 8/6/2019 Abap Enhancements

    14/15

    Double clicking on this exit will takes us to function builder (SE37) . Thisfunction exit has one exporting parameters and two importing parameters, we are interested in exporting

    parameter which is E_KUNNRof type KNA1-KUNNR i.e if we move the desired customer name to thisstructure(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-to-

    party field will come up with a predefinedcustomer .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-9If 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.

  • 8/6/2019 Abap Enhancements

    15/15