chapter 01_user exit and badi

Upload: bakkalibilal

Post on 02-Jun-2018

228 views

Category:

Documents


1 download

TRANSCRIPT

  • 8/10/2019 Chapter 01_User Exit and BADI

    1/39

    IBM Global Business Services

    IBM Corporation 2013User Exits | Dec-2008

    User Exits

  • 8/10/2019 Chapter 01_User Exit and BADI

    2/39

    IBM Global Business Services

    IBM Corporation 20132 Dec-2008User Exits |

    Objectives

    The participants will be able to:

    Discuss benefits to use User Exits

    Different types of user exits.

    Locate, code and implement User exit.

    Identify Projects and Enhancements and use the transactions CMOD and SMOD.

  • 8/10/2019 Chapter 01_User Exit and BADI

    3/39

  • 8/10/2019 Chapter 01_User Exit and BADI

    4/39

    IBM Global Business Services

    IBM Corporation 20134 Dec-2008User Exits |

    Overview

    There are some requirements which are not fulfilled by Standard Sap functionality.

    To Avoid making changes in Standard functionality, SAP provided some exits

    to accommodate custom functionality.

    Exits allows you to write own development and allow to change SAP functionality

    tosuityourneeds.

    Since they do not affect the source code and are named as per the SAP naming

    convention, they do not affect future software upgrade.

    If appropriate exit is not available as per your requirement, then it is mandatory to

    register SAP standard Object and get its access key to make changes.

    To obtain the access key for changing a SAP Standard object, either run transaction

    OSS1or go to the site www.service.sap.com.

  • 8/10/2019 Chapter 01_User Exit and BADI

    5/39

    IBM Global Business Services

    IBM Corporation 20135 Dec-2008User Exits |

    Different Enhancement Techniques

    SAP 3 Tier Architecture

    PRESENTATION :

    Screen Exits

    Menu Exits

    APPLICATION:

    Program exits ( Function Exits, BAdis, Business

    Transaction Events, Substitution Exits, Enhancement Spots)

    DATABASE

    Append Structure

  • 8/10/2019 Chapter 01_User Exit and BADI

    6/39

    IBM Global Business Services

    IBM Corporation 20136 Dec-2008User Exits |

    Information on existing User-Exits

    Using transaction SPRO, one can get detailed documentationon the Exits available for areas of concern.

  • 8/10/2019 Chapter 01_User Exit and BADI

    7/39

    IBM Global Business Services

    IBM Corporation 20137 Dec-2008User Exits |

    Function-Exits

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

    ----*

    * include zxf05u01.*

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

    ----*

    This INCLUDE

    program is where youwill write the

    customer-specific

    code.

    call customer-

    function 001...

    function

    exit_sapmf02k_001.

    include zxf05u01.

    endfunction.

    SAP Original Code

    SAPMF02K

    Function Module INCLUDE Program

    This INCLUDE program

    will not be overwritten

    with an SAP upgrade

    because it is not SAP

    original code.

  • 8/10/2019 Chapter 01_User Exit and BADI

    8/39

    IBM Global Business Services

    IBM Corporation 20138 Dec-2008User Exits |

    Call Customer-Function Versus Call Function

    The CALL CUSTOMER-FUNCTION

    statement will only execute the

    function module if the related

    enhancement is Active.

    call function EXIT_SAPMF02K_001

    Both of these CALL statements refer

    to the same function module

    EXIT_SAPMF02K_001.

  • 8/10/2019 Chapter 01_User Exit and BADI

    9/39

    IBM Global Business Services

    IBM Corporation 20139 Dec-2008User Exits |

    Business Case Scenario

    UPDATE LOG

    Vendor #Vendor name

    When the user updates a vendor record, you want toinsert a record into an update log that contains the

    vendor number and name of the updated record.

  • 8/10/2019 Chapter 01_User Exit and BADI

    10/39

    IBM Global Business Services

    IBM Corporation 201310 Dec-2008User Exits |

    Steps to Coding a Function-Exit

    1. Locate Function-Exit(s)

    2. Go to Function Module

    3. Create INCLUDE Program

    4. Code in INCLUDE Program

    5. Activate Function-Exit

  • 8/10/2019 Chapter 01_User Exit and BADI

    11/39

    IBM Global Business Services

    IBM Corporation 201311 Dec-2008User Exits |

    Locate Function-Exit(s)

    Open Main Program of Transaction Code to search function Exits

  • 8/10/2019 Chapter 01_User Exit and BADI

    12/39

    IBM Global Business Services

    IBM Corporation 201312 Dec-2008User Exits |

    Locate Function-Exit(s)

    In main program SAPMF02K,

    search for the string call

    customer-function to find all of

    the function-exit(s) in the main

    program.

  • 8/10/2019 Chapter 01_User Exit and BADI

    13/39

    IBM Global Business Services

    IBM Corporation 201313 Dec-2008User Exits |

    Locate Function-Exit(s)

    Double-click anywhere on

    the call customer-function

    001 statement to go to

    that line in the SAP program.

  • 8/10/2019 Chapter 01_User Exit and BADI

    14/39

    IBM Global Business Services

    IBM Corporation 201314 Dec-2008User Exits |

    Go to Function Module

    Double-click on 001 of the

    CALL CUSTOMER-FUNCTION

    001 statement in the SAPprogram to go to the function

    module EXIT_SAPMF02K_001.

  • 8/10/2019 Chapter 01_User Exit and BADI

    15/39

    IBM Global Business Services

    IBM Corporation 201315 Dec-2008User Exits |

    Create INCLUDE Program

    Double-click on the INCLUDE

    ZXF05U01 statement in the

    function module to create the

    INCLUDE program.

  • 8/10/2019 Chapter 01_User Exit and BADI

    16/39

    IBM Global Business Services

    IBM Corporation 201316 Dec-2008User Exits |

    Code in INCLUDE Program

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

    * INCLUDE ZXF05U01

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

    if sy-uname = SANGRAMC.

    endif.

    Write code in the include program. Whatever logic you add here will affect all

    SAP standard transaction where this

    particular User Exit is being called.

    Put all your code within the username

    check, while you are at the middle of theuser exit development. So, that your logic

    in the exit (which is incomplete now) does

    not affect others users in the system.

    At the end of the development, when you

    have tested that your logic is correct,

    remove the username check. So, the

    additional logic (tested & verified now) is

    now triggered for all users in the system.

  • 8/10/2019 Chapter 01_User Exit and BADI

    17/39

    IBM Global Business Services

    IBM Corporation 201317 Dec-2008User Exits |

    Activating Function-Exit

    X

    X

    PROJECT 1

    (can be activated/deactivated)

    Enhancement

    1

    Enhancement

    2

    Function

    Exit

    Screen

    Exit

    Function

    Exit

    PROJECT 2

    (can be activated/deactivated)

    Enhancement

    3

    Function

    Exit

    You do not actually activate a single function-exit; instead, you activate aPROJECT that will include your user-exit(s).

  • 8/10/2019 Chapter 01_User Exit and BADI

    18/39

    IBM Global Business Services

    IBM Corporation 201318 Dec-2008User Exits |

    User-Exit Transactions

    CMOD: This transaction allows you to create a PROJECT by identifying itsENHANCEMENT(S). After determining all of the ENHANCEMENTS that are part

    of the PROJECT, you will have to activate the PROJECT. Till you activate PROJECT

    logic written in function exit will not execute.

    SMOD: This transaction allows you to create an ENHANCEMENT, which you willinclude in a PROJECT, by identifying its COMPONENT(S). In many case SAP

    has already created an ENHANCEMENT for its pre-defined user-exits, in this case

    you will not need to use transaction SMOD; instead, you can direct add enhancemen

    in PROJECT using transaction CMOD.

  • 8/10/2019 Chapter 01_User Exit and BADI

    19/39

    IBM Global Business Services

    IBM Corporation 201319 Dec-2008User Exits |

    Transaction CMOD

    In transaction CMOD, type yourproject name and press the

    CREATE pushbutton.

    IBM Gl b l B i S i

  • 8/10/2019 Chapter 01_User Exit and BADI

    20/39

    IBM Global Business Services

    IBM Corporation 201320 Dec-2008User Exits |

    Transaction CMOD

    Once you SAVE your project,

    you can add as many

    enhancements as you want by

    pressing the SAP

    enhancements pushbutton.

    IBM Gl b l B i S i

  • 8/10/2019 Chapter 01_User Exit and BADI

    21/39

    IBM Global Business Services

    IBM Corporation 201321 Dec-2008User Exits |

    Transaction CMOD

    Add the enhancements you

    want included in

    the project.

  • 8/10/2019 Chapter 01_User Exit and BADI

    22/39

    IBM Gl b l B i S i

  • 8/10/2019 Chapter 01_User Exit and BADI

    23/39

    IBM Global Business Services

    IBM Corporation 201323 Dec-2008User Exits |

    Transaction SMOD

    With the name of the enhancement,

    you can display its components.

    IBM Global Business Services

  • 8/10/2019 Chapter 01_User Exit and BADI

    24/39

    IBM Global Business Services

    IBM Corporation 201324 Dec-2008User Exits |

    Transaction SMOD

    In the case of enhancement

    SAPMF02K, there is only one

    user-exita function-exit using

    the function module

    EXIT_SAPMF02K_001.

    IBM Global Business Services

  • 8/10/2019 Chapter 01_User Exit and BADI

    25/39

    IBM Global Business Services

    IBM Corporation 201325 Dec-2008User Exits |

    Additional Information

    You can use table MODACT to find the Project an Enhancement is included in.You can use table MODSAP to find the Enhancement for a Function Exit.

    Component or Function ExitEnhancement Name

    IBM Global Business Services

  • 8/10/2019 Chapter 01_User Exit and BADI

    26/39

    IBM Global Business Services

    IBM Corporation 201326 Dec-2008User Exits |

    Summary

    You should avoid making modifications/repairs to SAP objects/code wheneverpossible.

    It mandatory for users to register all manual changes to SAP source coding andSAP Dictionary objects through a procedure called SSCR.

    Function exit, screen exit and Append structure are different types of exits inSAP.

    CALL CUSTOMER-FUNCTION statement will only execute a exit functionmodule if the function module is activated.

    CMOD: This transaction allows you to create a PROJECT by identifying itsENHANCEMENT(S).

    SMOD: This transaction allows you to create an ENHANCEMENT, which you will

    include in a PROJECT, by identifying its COMPONENT(S).

    IBM Global Business Services

  • 8/10/2019 Chapter 01_User Exit and BADI

    27/39

    IBM Global Business Services

    IBM Corporation 201327 Dec-2008User Exits |

    Questions

    How do you obtain access key for changing a SAP standard object ? What are the steps for coding a Function Exits ?

    What does CMOD and SMOD do ?

  • 8/10/2019 Chapter 01_User Exit and BADI

    28/39

    IBM Global Business Services

  • 8/10/2019 Chapter 01_User Exit and BADI

    29/39

    IBM Global Business Services

    IBM Corporation 201329 Dec-2008User Exits |

    Objectives

    The participants will be able to: Describe Business Add-Ins and their advantages over User Exits.

    Analyze definition and Implementation of BAdi (Classic BADI) through transactions

    SE18 and SE19.

    Find Business Addins for a particular SAP transaction (if it has a BAdi).

    IBM Global Business Services

  • 8/10/2019 Chapter 01_User Exit and BADI

    30/39

    IBM Global Business Services

    IBM Corporation 201330 Dec-2008User Exits |

    What is BAdi

    Business Add-Ins are a new SAP enhancement technique based on ABAPObjects. (It has Interfaces & Methods)

    Business Add-Ins should be considered generalized Business Transaction Events

    that can be used to bundle program, menu and screen enhancements into a

    single add-in.

    Business Add-Ins have two parts: One is the Definition and the other is itsImplementation. The definition can either be SAP provided or user may also

    create it.

  • 8/10/2019 Chapter 01_User Exit and BADI

    31/39

    IBM Global Business Services

  • 8/10/2019 Chapter 01_User Exit and BADI

    32/39

    IBM Global Business Services

    IBM Corporation 201332 Dec-2008User Exits |

    BAdi : Where to Find

    Look for BAdi definition in IMG and in component hierarchy. (using transactionSE18)

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

    activate. (using transaction SE19)

    Enhancement's active components are called at runtime.

    IBM Global Business Services

  • 8/10/2019 Chapter 01_User Exit and BADI

    33/39

    IBM Global Business Services

    IBM Corporation 201333 Dec-2008User Exits |

    BAdi Definition (SE18)Classic BADI

    In the Definition view, an application programmer predefines exit points in asource that allow customers to attach additional software to standard SAP source

    code without having to modify the original object.

    To define a BAdi use Sap Menu -> Tools -> ABAP Workbench -> Utilities ->

    Business Add-Ins -> Definition (transaction SE18).

    Call the interface at the appropriate point in application program, where you want

    to provide an exit to the customer

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

    IBM Global Business Services

  • 8/10/2019 Chapter 01_User Exit and BADI

    34/39

    IBM Global Business Services

    IBM Corporation 201334 Dec-2008User Exits |

    BAdi Implementation (SE19)Classic BADI

    In the Implementation view, the usersof Business Add-Ins can customizethe logic they need or use a standardlogic if one is available.

    Find the suitable Business Add-Ins

    present in system (Use IMG orComponent hierarchy)

    Use Add-Ins Documentation tounderstand functionality & to decidewhich Definition to implement.

    Use SAP Menu ABAP Workbench->Utilities -> Business Add-Ins ->

    Implementation (transaction SE19)

    IBM Global Business Services

  • 8/10/2019 Chapter 01_User Exit and BADI

    35/39

    IBM Corporation 201335 Dec-2008User Exits |

    BAdi Implementation : Sequence of steps

    1. Find the corresponding BAdi for the SAP transaction2. Create a custom Implementation for the BAdi

    3. From the methods available in the BAdi and select the appropriate method

    4. Enter custom code in the method and activate

    5. Execute SAP transaction and test if method with custom code is being invoked

  • 8/10/2019 Chapter 01_User Exit and BADI

    36/39

    IBM Global Business Services

  • 8/10/2019 Chapter 01_User Exit and BADI

    37/39

    IBM Corporation 201337 Dec-2008User Exits |

    Implement Method

    Select correct method from implementation and write your own code using BADIparameters.

    Activate implementation. This is mandatory as till then new implementation is not

    executed by SAP.

    Methods and Parameters

  • 8/10/2019 Chapter 01_User Exit and BADI

    38/39

    IBM Global Business Services

  • 8/10/2019 Chapter 01_User Exit and BADI

    39/39

    Questions

    What are BAdis ? Which transactions are used for BAdi Definition and Implementation ?

    How do you locate BAdis defined by SAP for a SAP standard transaction ?