SlideShare ist ein Scribd-Unternehmen logo
1 von 46
Downloaden Sie, um offline zu lesen
SAP Development 4.0 to 6.20 Delta Training                                    BAdIs




                   Business Consulting Services




         Business Add-In’s


                   November, 2003
                                                               deeper


                                                    © Copyright IBM Corporation 2003




© Copyright IBM Corporation 2003             15.1      November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                 BAdIs


                   Business Consulting Services




     Lesson Objectives


         After completing this lesson you will be able to :
           Understand what Business Add In’s (BAdIs) are
           Define BAdIs
           Implement BAdIs
           Use BAdIs
           Create an implementation for an existing SAP BAdI
           Create Multiple Use BAdIs
           Create Filter Dependent BAdI




     2               ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003           © Copyright IBM Corporation 2003




© Copyright IBM Corporation 2003                                          15.2   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                   BAdIs


                 Business Consulting Services




     Introduction


         Traditional way of doing code modifications – Exits
         3 Tier Architecture
           – PRESENTATION :
                  Field Exits
                  Screen Exits
                  Menu Exits
           – APPLICATION:
                  Programs -> Program exits -> call customer function -> Include
           – DATABASE
                  Table -> SE11 -> Goto -> Append Structure

         With BAdIs you can make changes only at the Application Layer.



     3             ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003               © Copyright IBM Corporation 2003




 •   The traditional way of doing code modifications was via User exits.
 •   As per SAP’s 3 Tier Architecture, at the Presentation layer you had Field Exits, Screen
     Exits and Menu Exits. At the Application layer you had Program exits, at the Database
     layer you could Append structures to the existing SAP structures.




© Copyright IBM Corporation 2003                                        15.3       November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                 BAdIs


                    Business Consulting Services




     BAdIs


         Business Add-Ins are a new SAP enhancement technique based on ABAP
         Objects
         They can be inserted into the SAP system based on specific user
         requirements
         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.
         Each Business Add-In has :
             – at least one Business Add-In definition
             – a Business Add-In interface
             – a Business Add-In class that implements the interface



     4               ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003           © Copyright IBM Corporation 2003




 •   In order to enhance a program a Business Add-In must first be defined
 •   Subsequently two classes are automatically generated :
         –   An interface with ‘IF_EX_’ inserted between the first and second characters of the
             BAdI name
         –   An adapter class with ‘CL_EX_’ inserted between the first and second characters
             of the BAdI name.
 •   The Application developer creates an interface for this Add-In
 •   Enhancement management generates an adapter class for implementing the interface
 •   This opens a path for custom implementations to be created by partners or customers.
 •   By instantiating the adapter class in the application program, its corresponding methods
     can be used




© Copyright IBM Corporation 2003                                          15.4   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                               BAdIs


                 Business Consulting Services




     BAdI Enhancement options


         In Business Add-Ins, all the components of an enhancement option are
         grouped together
           – Program Enhancements: Functional enhancement of the program are defined in
             the form of interface methods and can be used with or without Menu
             Enhancements or Screen Enhancements
           – Menu Enhancements: Function codes can be entered for a BAdI for the
             corresponding menu entries in the user interface definition.
           – Screen Enhancements: Subscreen areas can be entered for a Business Add-In.
             Screen enhancements can be implemented for these in the form of subscreen
             screens.




     5             ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003           © Copyright IBM Corporation 2003




© Copyright IBM Corporation 2003                                        15.5   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                              BAdIs


                 Business Consulting Services




     Defining BAdIs
         SE18



                                                                              Enter BADI name




                                                                              Click on CREATE




     6            ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003           © Copyright IBM Corporation 2003




 •   To define a BAdI use Sap Menu -> Tools -> ABAP Workbench -> Utilities -> Business
     Ad-Ins -> Definition
 •   For Application developers to include BAdIs in their program they need to define an
     interface for their enhancement in the ‘Business Add-Ins Initial Maintenance Screen’.




© Copyright IBM Corporation 2003                                       15.6   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                             BAdIs


                 Business Consulting Services




     Defining BAdIs – Attributes




                                                                                              Enter short text




                                                                              BADI class is automatically created




     7            ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003                          © Copyright IBM Corporation 2003




 •   When a BAdI is created, BADI class gets automatically created with the suffix ‘CL_EX_’
     after the first character of the BAdI name.
 •   Package : Specifies the Package in which this BAdI resides.
 •   Multiple use : With this option you can have multiple implementations for the same BAdI
 •   Filter-Dependent : Business Add-Ins may be implemented depending on a specific filter
     value (example, country-specific versions: Distinct implementations of the BAdI can be
     created for each country). A filter type must be entered when defining your
     enhancement (a country or industry sector, for example). All methods created in the
     enhancement's interface have filter value 'FLT_VAL' as their import parameter. The
     method then selects the active implementation based on the data provided in the filter
     value




© Copyright IBM Corporation 2003                                       15.7                 November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                              BAdIs


                Business Consulting Services




     BADI Definition - Save




                                                                             Enter Package name




     8           ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   Save the BADI to a Package. (Z_DELTA_STUDENT##)




© Copyright IBM Corporation 2003                                      15.8    November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                  BAdIs


                Business Consulting Services




     Defining BAdIs



                                                                             Package name populated




                                                                             BAdI class created




     9           ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003                © Copyright IBM Corporation 2003




 •   A BADI class ZCL_EX_DELTA_7_0_DEMO1 is created automatically.




© Copyright IBM Corporation 2003                                      15.9       November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                BAdIs


                 Business Consulting Services




     Defining BAdIs - Interface




                                                                                  BADI Interface is
                                                                                created automatically
                                                                                 To edit double click
                                                                                   on the interface




     10            ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   An interface is created automatically with the suffix ‘IF_EX_’ after the first character of
     the BAdI name
 •   When you double click the interface ‘ZIF_EX_DELTA_7_0_DEMO1 you will be taken
     into the class builder where you can define the methods, parameters and exceptions for
     that interface




© Copyright IBM Corporation 2003                                        15.10   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                BAdIs


                 Business Consulting Services




     Defining BAdIs – Interface methods



                                                                                Method name


                                                                                Method type




     11            ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   Specify the methods in the Class Builder for the interface
 •   Instance methods can access all of the attributes of a class, and can trigger all of the
     events of the class
 •   Static methods can only access static attributes and trigger static events
 •   Click on the Parameters button to specify any Import/Export parameters for the method




© Copyright IBM Corporation 2003                                        15.11   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                 BAdIs


                  Business Consulting Services




     Defining BAdIs – Interface methods - parameters




             Import and
          Export parameters




     12             ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   The Import/Export parameters for the method are specified in the ‘Parameters’ section
 •   The type specifies whether the parameter is an Importing, Exporting, Changing or
     Returning parameter.
 •   Check the Optional field if it is not a mandatory parameter
 •   The type, default value and description of the parameter can be specified




© Copyright IBM Corporation 2003                                         15.12   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                BAdIs


                  Business Consulting Services




      Defining BAdIs – Exceptions




     Exceptions




      13           ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •    You can specify any exceptions in the Exceptions section.
 •    For class based exceptions, check the checkbox ‘Exception Classes’.




© Copyright IBM Corporation 2003                                        15.13   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                           BAdIs


                    Business Consulting Services




     BADI Implementation
          SE19




                                                                                   Enter Implementation name


                                                                                     Click on create




                                                                                             Enter the BAdI
                                                                                             Definition name




     14               ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003                    © Copyright IBM Corporation 2003




 •   To create an implementation, proceed as follows:
          –   Choose ABAP Workbench -> Utilities -> Business Add-Ins (transaction SE19) from
              the SAP menu
          –   Enter a name for the implementation and choose Create.
          –   Enter the name of the BAdI you want to create an implementation for in the dialog
              box that appears.




© Copyright IBM Corporation 2003                                           15.14          November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                    BAdIs


                     Business Consulting Services




     BAdI Implementation




     Double click on
     the method to modify
     method code




     15                ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   During implementation creation, a class for implementing the enhancement's interface is
     also created
 •   Navigate to the Class Builder by double-clicking the method.




© Copyright IBM Corporation 2003                                            15.15   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                 BAdIs


                 Business Consulting Services




     Implementing BAdIs: Method implementation




                                                                                 Modify the method
                                                                                   code within the
                                                                               METHOD/ENDMETHOD
                                                                               statements and activate




     16           ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003              © Copyright IBM Corporation 2003




 •   Insert the source code between the method and endmethod statements and activated.
 •   Exception handling for the method can be handled in this section.




© Copyright IBM Corporation 2003                                       15.16    November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                  BAdIs


                    Business Consulting Services




     Using a BAdI




     17              ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   When a BAdI is created, the enhancement manager automatically generates a class that
     implement the interface
 •   In order to be able to call static methods, you must declare the corresponding class in
     ABAP Objects using the ‘class … definition load’ statement
 •   In the example having created a BAdI for division, you can program the call for the BAdI
     in the following manner:
          –   Create an Interface Reference Variable in the program ‘L_BADI_INSTANCE’
          –   Perform the statement ‘call method cl_exithandler …’ using the BAdI and the
              interface reference variable.
          –   Call method DIVIDE_NUMBERS using the interface reference variable
              L_BADI_INSTANCE.




© Copyright IBM Corporation 2003                                          15.17   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                BAdIs


                  Business Consulting Services




     Create an Implementation for an SAP provided BAdI


          Find the corresponding BAdI for the SAP transaction
          Create a custom Implementation for the BAdI
          From the methods available in the BAdI and select the appropriate method
          Enter custom code in the method and activate
          Execute SAP transaction and test if method with custom code is being
          invoked




     18            ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




© Copyright IBM Corporation 2003                                        15.18   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                   BAdIs


                     Business Consulting Services




     Finding a BAdI – Transaction VD02




                                                                                    Select System->Status
                                                                                    from the drop down menu




     19               ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   To find a BAdI for any SAP transaction do the following:
          –   Click on System->Status
          –   Double click on the program name
          –   Once inside the program search for ‘CL_EXITHANDLER=>GET_INSTANCE’.
              Make sure the radiobutton – In main program is checked
          –   A list of all the programs with call to the BAdIs will be listed.
          –   The export parameter ‘EXIT_NAME’ for the method GET_INSTANCE of class
              CL_EXITHANDLER will have the user exit assigned to it.
          –   The changing parameter ‘INSTANCE’ will have the interface assigned to it.




© Copyright IBM Corporation 2003                                           15.19   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                             BAdIs


                Business Consulting Services




     Finding a BAdI – Transaction VD02




                                                                              Double click on the
                                                                              program name




     20          ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003                           © Copyright IBM Corporation 2003




© Copyright IBM Corporation 2003                                      15.20                 November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                              BAdIs


                Business Consulting Services




     Finding a BAdI – Source program




                                                                                   Do a search on
                                                                                   CL_EXITHANDLER=>
                                                                                   GET_INSTANCE




     21          ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




© Copyright IBM Corporation 2003                                      15.21   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                               BAdIs


                Business Consulting Services




     Finding a BAdI – Search results




                                                                                  Three BAdIs used
                                                                                  in this program.
                                                                                  Double click required
                                                                                  BAdI to see the
                                                                                  source code




     22           ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   Double click on the method to enter the source code.




© Copyright IBM Corporation 2003                                       15.22   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                              BAdIs


                Business Consulting Services




     Finding a BAdI – Call to a BAdI in the source code




                                                                               BAdI being used




                                                                               Interface reference
                                                                               Variable for the BAdI




     23          ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




© Copyright IBM Corporation 2003                                      15.23   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                               BAdIs


                Business Consulting Services




     Finding a BAdI – Interface reference to the BAdI




                                                                                    Interface reference
                                                                                    Variable defined




     24           ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   If the BAdI name is not specified in the CL_EXITHANDLER=>GET_INSTANCE method
     call, you can find out the BAdI name by removing the prefix IF_EX_ from the interface
     name.




© Copyright IBM Corporation 2003                                       15.24   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                   BAdIs


                    Business Consulting Services




     Using an SAP BAdI – Create a Custom Implementation

     SE19

                                                                                                 Enter the
                                                                                              implementation
                                                                                                   name



                                                                                           Click on CREATE




                                                                                             Enter the name
                                                                                               of the BAdI




     25               ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   To create a custom implementation for an SAP defined BAdI do the following:
          –   Go to transaction SE19
          –   Enter a name for the BAdI
          –   Hit the ‘Create’ button
          –   The BAdI definition selection popup will be displayed
          –   Enter the name of the standard SAP BADI that you want to implement




© Copyright IBM Corporation 2003                                           15.25   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                               BAdIs


                 Business Consulting Services




     BAdI Implementation – Attributes



                                                                                    Enter description




     26           ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   Enter the description for the custom implementation
 •   Click on the Activate button to activate the implementation




© Copyright IBM Corporation 2003                                       15.26   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                BAdIs


                 Business Consulting Services




     BAdI Implementation – Interface methods




                                                                                   Click on the interface
                                                                                   tab to view the available
                                                                                   methods




                                                                                  Double click on method
                                                                                  SAVE_DATA to modify it




     27            ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   In the interfaces tab you will find a list of methods included in the BAdI Interface
 •   Double clicking on any of the methods will take you into the Class Builder where you can
     enter custom code for the corresponding method




© Copyright IBM Corporation 2003                                        15.27   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                BAdIs


                Business Consulting Services




     BAdI Implementation – Class builder




                                                                               Enter custom code




     28           ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003             © Copyright IBM Corporation 2003




 •   In our example we have chosen the SAVE_DATA method to enter our code changes
 •   Double clicking on the SAVE_DATA method takes us into the class builder
 •   You can enter your code changes between the method, endmethod statements
 •   Enter the custom code that will be executed when customer data is saved in transaction
     VD02.




© Copyright IBM Corporation 2003                                       15.28   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                   BAdIs


                Business Consulting Services




     BAdIs – Execute the Change customer transaction

      VD02


                                                                               Click on SAVE button




                                                                               Change name of Customer




     29           ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003                © Copyright IBM Corporation 2003




 •   Go into the change customer transaction VD02 and change the name of the customer
 •   Click on the SAVE button.
 •   This should invoke the BAdI – CUSTOMER_ADD_DATA and subsequently execute the
     custom implementation.




© Copyright IBM Corporation 2003                                       15.29      November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                  BAdIs


                Business Consulting Services




     BAdI Implementation – Invoked by VD02




                                                                              Custom code for method
                                                                                 invoked via BAdI
                                                                              CUSTOMER_ADD_DATA




     30          ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003                © Copyright IBM Corporation 2003




 •   A break point is hard-coded into the method SAVE_DATA.
 •   Execute transaction VD02 and change the customer address.
 •   When you hit the SAVE button, the code entered in the SAVE_DATA method is
     executed.




© Copyright IBM Corporation 2003                                      15.30      November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                                                BAdIs


                    Business Consulting Services




     Multiple Use BAdIs


          Single Use Business Add-Ins                                              Multiple Use Business Add-Ins
            – Do NOT select the Multiple use checkbox                                – Select the Multiple use checkbox from
              from the Administration tab when defining                                the Administration tab when creating the
              a Single Use BAdI                                                        BAdI definition
            – BAdI has a single Implementation                                       – BAdI has multiple implementations
            – Similar to procedures                                                  – Similar to event calls
            – Return values can be expected                                          – Cannot expect return values
            – Can use importing, changing and                                        – Can use importing and changing
              returning parameters                                                     parameters
            – N/A                                                                    – For multiple implementations there is no
                                                                                       sequence control because at the time of
                                                                                       BAdI definition it does not know which
                                                                                       implementation will be active
            – A single implementation will be triggered                              – All active implementations will be
              by the application program                                               triggered by the application program
                                                                                       using the BAdI

     31               ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003                                         © Copyright IBM Corporation 2003




© Copyright IBM Corporation 2003                                           15.31                                November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                    BAdIs


                      Business Consulting Services




     Multi Use BAdIs – CUSTOMER_ADD_DATA Definition




     SAP defined BAdI –
     CUSTOMER_ADD_DATA




     Multiple use
     Button checked




     32                ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   CUSTOMER_ADD_DATA is an SAP defined BAdI that is invoked by the transaction
     VD02




© Copyright IBM Corporation 2003                                            15.32   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                         BAdIs


                Business Consulting Services


     Multi Use BAdIs – Custom Implementation for BAdI –
     CUSTOMER_ADD_DATA




                                                                              Create a second implementation
                                                                              for BAdI CUSTOMER_ADD_DATA


                                                                              Click on CREATE




                                                                              Specify BAdI name




     33          ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003                       © Copyright IBM Corporation 2003




 •   Create a second implementation for BAdI CUSTOMER_ADD_DATA




© Copyright IBM Corporation 2003                                      15.33              November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                   BAdIs


                Business Consulting Services




     Multi Use BAdIs – Interface method SAVE_DATA




                                                                              Double click on method
                                                                              SAVE_DATA




     34          ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003                 © Copyright IBM Corporation 2003




 •   Double click on method SAVE_DATA TO enter the class builder where you can enter
     custom code for this method.




© Copyright IBM Corporation 2003                                      15.34       November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                      BAdIs


                 Business Consulting Services




     Multi Use BAdIs – Modify method SAVE_DATA




                                                                               Enter custom code for
                                                                               method SAVE_DATA




     35           ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003                   © Copyright IBM Corporation 2003




 •   Enter the custom code for the method SAVE_DATA in the class builder and activate.
 •   Activate the BAdI Implementation before exiting.




© Copyright IBM Corporation 2003                                       15.35         November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                BAdIs


                 Business Consulting Services




     Multi Use BAdIs – View implementations for BAdI

  SE18
                                                                                 Select to display list of
                                                                                 Implementations for BAdI
                                                                                 CUSTOMER_ADD_DATA




                                                                                      Displays list of
                                                                                      Implementations




     36            ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   To view all implementation for BAdi CUSTOMER_ADD_DATA go to the BAdI definition
     in se18. Click on Implementation->Display.
 •   A list of all the Implementations is displayed.
 •   You can CREATE, CHANGE, DISPLAY and DELETE Implementations from here.
 •   Both BAdIs will be triggered when the customer data is modified in transaction VD02
     and saved.




© Copyright IBM Corporation 2003                                        15.36   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                 BAdIs


                   Business Consulting Services




     Filter Dependent BAdIs


          Business Add-Ins can be implemented based on a specific filter value
          If you want to call the implementation of a Business Add-In depending not
          only on one filter value but on various values, you can enter the name of a
          structure into the Filter type field. The structure can consist of several data
          elements that fulfill the above conditions for data elements




     37             ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




© Copyright IBM Corporation 2003                                         15.37   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                           BAdIs


                          Business Consulting Services




     Filter Dependent BAdIs – BAdI Definition

                              SE18




      Click checkbox for
      Filter Dependent BAdIs



          Enter Filter type




     38                       ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   A filter type can be a data element or a structure. A data element must fulfill the following
     criteria:
          –     The data element's domain may contain a maximum of 30 characters and must be
                of type Character.
          –     The data element must 1). either have a search help with a search help parameter
                of the same type as the data element and this parameter must serve as both the
                import and export parameter or 2). the element's domain must have fixed domain
                values or a value table containing a column with the same type as the data
                element.




© Copyright IBM Corporation 2003                                                   15.38   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                   BAdIs


                 Business Consulting Services




     Filter Dependent BAdIs – BAdI Definition



                                                                               Enter text

                                                                               Double click on
                                                                               the Interface to
                                                                               add parameters
                                                                               and methods




     39           ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003                © Copyright IBM Corporation 2003




 •   When you double click on the interface it takes you to the class builder where you can
     add methods, parameters, and exceptions to the interface.




© Copyright IBM Corporation 2003                                       15.39      November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                               BAdIs


                 Business Consulting Services




     Filter Dependent BAdIs – Interface - Method Definition




     40           ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   Now create an interface with a method. Be aware that for each method you create in the
     interface of a filter-dependent enhancement, the appropriate filter value must be defined
     as the import parameter so that the application program can provide the filter value to
     the enhancement method. The method then selects the active implementation for that
     value.




© Copyright IBM Corporation 2003                                       15.40   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                        BAdIs


                      Business Consulting Services




      Filter Dependent BAdIs – Interface – Parameter Definition




      Create parameter to
           export tax rate




     FLT_VAL parameter
       preset for method




      41                   ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •    The filter value is declared using parameter flt_val and is preset in the list of parameters.




© Copyright IBM Corporation 2003                                                15.41   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                  BAdIs


                Business Consulting Services




     Filter Dependent BAdIs – Implementation




                                                                              Create BAdI Implementation


                                                                              Select CREATE button




                                                                              Enter name of BAdI




     42          ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003                © Copyright IBM Corporation 2003




© Copyright IBM Corporation 2003                                      15.42      November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                         BAdIs


                           Business Consulting Services




       Filter Dependent BAdIs – BAdI Implementation

                  SE19




     Click on button to
     create an entry
     for filter value


     Select a value from
     the search help or
     enter a valid value




       43                   ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •    Create a BAdI




© Copyright IBM Corporation 2003                                                 15.43   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                      BAdIs


                        Business Consulting Services




     Filter Dependent BAdIs – BAdI Implementation



    Select the
    Interface tab




    Double click on
    the Method to
    enter source code




     44                  ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




© Copyright IBM Corporation 2003                                              15.44   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                      BAdIs


                       Business Consulting Services




     Filter Dependent BAdIs – Method code


          Save and activate



          Enter code for the
          Method to calculate
          the tax rate based on
          the company code in
          Parameter FLT_VAL




     45                  ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •   The parameter FLT_VAL will have the company code value passes to the
     implementation.
 •   Move the tax rate to the export parameter Z_TAX_RATE.
 •   Save and Activate the method




© Copyright IBM Corporation 2003                                              15.45   November 2003, v1
SAP Development 4.0 to 6.20 Delta Training                                                                        BAdIs


                          Business Consulting Services




      Filter Dependent BAdIs – Source code to Invoke BAdI




      Selection screen
      parameter for
      Company code

     Call BADI from
     within the program




     Call method
     get_bukrs passing
     the company code
     The Tax rate is
     returned




      46                   ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003            © Copyright IBM Corporation 2003




 •    A second implementation can be created wherein a different set of company codes can
      be specified.




© Copyright IBM Corporation 2003                                                15.46   November 2003, v1

Weitere ähnliche Inhalte

Was ist angesagt?

Sap bpc embedded training.pdf
Sap bpc embedded training.pdfSap bpc embedded training.pdf
Sap bpc embedded training.pdfRishi1431
 
XLSX Upload - IN SAP GUI and WDA
XLSX Upload - IN SAP GUI and WDAXLSX Upload - IN SAP GUI and WDA
XLSX Upload - IN SAP GUI and WDABenu Mariantony
 
Blueprint process questions_ics
Blueprint process questions_icsBlueprint process questions_ics
Blueprint process questions_icsranganv72
 
Start learning sap bpc by yourself
Start learning sap bpc by yourselfStart learning sap bpc by yourself
Start learning sap bpc by yourselfgriteshkaran
 
Z sap boe-2016-techws-04_vs_fiori-app-with-eclipseluna-accessing-zsap-system
Z sap boe-2016-techws-04_vs_fiori-app-with-eclipseluna-accessing-zsap-systemZ sap boe-2016-techws-04_vs_fiori-app-with-eclipseluna-accessing-zsap-system
Z sap boe-2016-techws-04_vs_fiori-app-with-eclipseluna-accessing-zsap-systemNagendra Babu
 
Overview presentation intercompany integration solution for sap business one
Overview presentation intercompany integration solution for sap business oneOverview presentation intercompany integration solution for sap business one
Overview presentation intercompany integration solution for sap business onewalldorf_share
 
Sap bpc 10 package
Sap bpc 10 packageSap bpc 10 package
Sap bpc 10 packagegriteshkaran
 
Lista eh ps
Lista eh psLista eh ps
Lista eh psJarlei N
 
Performance tuning in sap bi 7.0
Performance tuning in sap bi 7.0Performance tuning in sap bi 7.0
Performance tuning in sap bi 7.0gireesho
 
Practitioner perspective-erp-on-hana-and-fi-analytics 2015
Practitioner perspective-erp-on-hana-and-fi-analytics 2015Practitioner perspective-erp-on-hana-and-fi-analytics 2015
Practitioner perspective-erp-on-hana-and-fi-analytics 2015Benedict Yong (杨腾翔)
 
Variables in sap bi
Variables in sap biVariables in sap bi
Variables in sap bishabari76
 
Testing SAP HANA applications with SAP LoadRunner by HP
Testing SAP HANA applications with SAP LoadRunner by HPTesting SAP HANA applications with SAP LoadRunner by HP
Testing SAP HANA applications with SAP LoadRunner by HPSAP Solution Extensions
 
Bpc 10.1 classic training
Bpc 10.1 classic trainingBpc 10.1 classic training
Bpc 10.1 classic traininggriteshkaran
 
Bw writing routines in update rules
Bw writing routines in update rulesBw writing routines in update rules
Bw writing routines in update rulesknreddyy
 

Was ist angesagt? (20)

Sap bpc embedded training.pdf
Sap bpc embedded training.pdfSap bpc embedded training.pdf
Sap bpc embedded training.pdf
 
XLSX Upload - IN SAP GUI and WDA
XLSX Upload - IN SAP GUI and WDAXLSX Upload - IN SAP GUI and WDA
XLSX Upload - IN SAP GUI and WDA
 
Blueprint process questions_ics
Blueprint process questions_icsBlueprint process questions_ics
Blueprint process questions_ics
 
Resume_(1)
Resume_(1)Resume_(1)
Resume_(1)
 
Start learning sap bpc by yourself
Start learning sap bpc by yourselfStart learning sap bpc by yourself
Start learning sap bpc by yourself
 
Z sap boe-2016-techws-04_vs_fiori-app-with-eclipseluna-accessing-zsap-system
Z sap boe-2016-techws-04_vs_fiori-app-with-eclipseluna-accessing-zsap-systemZ sap boe-2016-techws-04_vs_fiori-app-with-eclipseluna-accessing-zsap-system
Z sap boe-2016-techws-04_vs_fiori-app-with-eclipseluna-accessing-zsap-system
 
Overview presentation intercompany integration solution for sap business one
Overview presentation intercompany integration solution for sap business oneOverview presentation intercompany integration solution for sap business one
Overview presentation intercompany integration solution for sap business one
 
Sap bpc 10 package
Sap bpc 10 packageSap bpc 10 package
Sap bpc 10 package
 
Lista eh ps
Lista eh psLista eh ps
Lista eh ps
 
PSD Enablement Session: "News for SAP Platform Partners. The "Manage my Partn...
PSD Enablement Session: "News for SAP Platform Partners. The "Manage my Partn...PSD Enablement Session: "News for SAP Platform Partners. The "Manage my Partn...
PSD Enablement Session: "News for SAP Platform Partners. The "Manage my Partn...
 
Performance tuning in sap bi 7.0
Performance tuning in sap bi 7.0Performance tuning in sap bi 7.0
Performance tuning in sap bi 7.0
 
SAP Integration With Excel - Advanced Guide
SAP Integration With Excel - Advanced GuideSAP Integration With Excel - Advanced Guide
SAP Integration With Excel - Advanced Guide
 
Practitioner perspective-erp-on-hana-and-fi-analytics 2015
Practitioner perspective-erp-on-hana-and-fi-analytics 2015Practitioner perspective-erp-on-hana-and-fi-analytics 2015
Practitioner perspective-erp-on-hana-and-fi-analytics 2015
 
SAP Integration with Excel - Basic Guide
SAP Integration with Excel - Basic GuideSAP Integration with Excel - Basic Guide
SAP Integration with Excel - Basic Guide
 
Variables in sap bi
Variables in sap biVariables in sap bi
Variables in sap bi
 
B1 ICO add Config
B1 ICO add ConfigB1 ICO add Config
B1 ICO add Config
 
Kranthi 3.5 exp
Kranthi 3.5 expKranthi 3.5 exp
Kranthi 3.5 exp
 
Testing SAP HANA applications with SAP LoadRunner by HP
Testing SAP HANA applications with SAP LoadRunner by HPTesting SAP HANA applications with SAP LoadRunner by HP
Testing SAP HANA applications with SAP LoadRunner by HP
 
Bpc 10.1 classic training
Bpc 10.1 classic trainingBpc 10.1 classic training
Bpc 10.1 classic training
 
Bw writing routines in update rules
Bw writing routines in update rulesBw writing routines in update rules
Bw writing routines in update rules
 

Andere mochten auch

SITIST 2015 Dev - Abap on Hana
SITIST 2015 Dev - Abap on HanaSITIST 2015 Dev - Abap on Hana
SITIST 2015 Dev - Abap on Hanasitist
 
Dassian GOVCON Overview
Dassian GOVCON OverviewDassian GOVCON Overview
Dassian GOVCON OverviewDassian Inc.
 
What is an_sap_business_blueprint
What is an_sap_business_blueprintWhat is an_sap_business_blueprint
What is an_sap_business_blueprintPrashant Tyagi
 
Kindness to parents
Kindness to parentsKindness to parents
Kindness to parentsAabid Khan
 
Pricing Routine In Vofm
Pricing Routine In VofmPricing Routine In Vofm
Pricing Routine In Vofmgueste6b4e7
 

Andere mochten auch (8)

SITIST 2015 Dev - Abap on Hana
SITIST 2015 Dev - Abap on HanaSITIST 2015 Dev - Abap on Hana
SITIST 2015 Dev - Abap on Hana
 
Dassian GOVCON Overview
Dassian GOVCON OverviewDassian GOVCON Overview
Dassian GOVCON Overview
 
What is an_sap_business_blueprint
What is an_sap_business_blueprintWhat is an_sap_business_blueprint
What is an_sap_business_blueprint
 
Why sap hana
Why sap hanaWhy sap hana
Why sap hana
 
Kindness to parents
Kindness to parentsKindness to parents
Kindness to parents
 
Pricing Routine In Vofm
Pricing Routine In VofmPricing Routine In Vofm
Pricing Routine In Vofm
 
SAP HANA Platform
SAP HANA Platform SAP HANA Platform
SAP HANA Platform
 
SAP HANA - Understanding the Basics
SAP HANA - Understanding the Basics SAP HANA - Understanding the Basics
SAP HANA - Understanding the Basics
 

Ähnlich wie B adi

AD404 - Extend your Social Business by integrating SAP Solutions
AD404 - Extend your Social Business by integrating SAP SolutionsAD404 - Extend your Social Business by integrating SAP Solutions
AD404 - Extend your Social Business by integrating SAP SolutionsChristian Holsing
 
Ibm connect 2014 recap asean perspective
Ibm connect 2014 recap   asean perspectiveIbm connect 2014 recap   asean perspective
Ibm connect 2014 recap asean perspectiveJoseph George
 
Portal Integration with SAP BusinessObjects (SDK)
Portal Integration with SAP BusinessObjects (SDK)Portal Integration with SAP BusinessObjects (SDK)
Portal Integration with SAP BusinessObjects (SDK)DMIMarketing
 
SapInsideTrackBonn Sap&Adobe
SapInsideTrackBonn   Sap&AdobeSapInsideTrackBonn   Sap&Adobe
SapInsideTrackBonn Sap&Adobesergio.ferrari
 
SAP BASIS Training in Delhi in 2022
SAP BASIS Training in Delhi in 2022SAP BASIS Training in Delhi in 2022
SAP BASIS Training in Delhi in 2022ERP Delhi
 
Abhinav_Kumar_ABAP_4 yes
Abhinav_Kumar_ABAP_4 yesAbhinav_Kumar_ABAP_4 yes
Abhinav_Kumar_ABAP_4 yesabhinavkumar8
 
Integrating sap with web sphere portal
Integrating sap with web sphere portal Integrating sap with web sphere portal
Integrating sap with web sphere portal Djalma Britto
 
Dell Boomi Hyderabad meetup
Dell Boomi Hyderabad meetupDell Boomi Hyderabad meetup
Dell Boomi Hyderabad meetupVijay Reddy
 
C bu06 planning_your_cloud_education
C bu06 planning_your_cloud_educationC bu06 planning_your_cloud_education
C bu06 planning_your_cloud_educationMegan Irvine
 
Data Analytics Strategies & Solutions for SAP customers
Data Analytics Strategies & Solutions for SAP customersData Analytics Strategies & Solutions for SAP customers
Data Analytics Strategies & Solutions for SAP customersVisual_BI
 
Bdi Systems
Bdi SystemsBdi Systems
Bdi Systemsaryan990
 
Learn why Microsoft Power BI is an Undisputed Market Leader?
Learn why Microsoft Power BI is an Undisputed Market Leader?Learn why Microsoft Power BI is an Undisputed Market Leader?
Learn why Microsoft Power BI is an Undisputed Market Leader?Visual_BI
 
C bu07 cloud_offering_decoder
C bu07 cloud_offering_decoderC bu07 cloud_offering_decoder
C bu07 cloud_offering_decoderMegan Irvine
 
Ozone profile general presentation 1
Ozone profile general presentation 1Ozone profile general presentation 1
Ozone profile general presentation 1Natalliamaroz
 

Ähnlich wie B adi (20)

022006 zaidi badi
022006   zaidi badi022006   zaidi badi
022006 zaidi badi
 
AD404 - Extend your Social Business by integrating SAP Solutions
AD404 - Extend your Social Business by integrating SAP SolutionsAD404 - Extend your Social Business by integrating SAP Solutions
AD404 - Extend your Social Business by integrating SAP Solutions
 
IBM Connect 2013 - AD405
IBM Connect 2013 - AD405IBM Connect 2013 - AD405
IBM Connect 2013 - AD405
 
Ibm connect 2014 recap asean perspective
Ibm connect 2014 recap   asean perspectiveIbm connect 2014 recap   asean perspective
Ibm connect 2014 recap asean perspective
 
Desktop intelligence compatibility pack
Desktop intelligence compatibility packDesktop intelligence compatibility pack
Desktop intelligence compatibility pack
 
Portal Integration with SAP BusinessObjects (SDK)
Portal Integration with SAP BusinessObjects (SDK)Portal Integration with SAP BusinessObjects (SDK)
Portal Integration with SAP BusinessObjects (SDK)
 
SapInsideTrackBonn Sap&Adobe
SapInsideTrackBonn   Sap&AdobeSapInsideTrackBonn   Sap&Adobe
SapInsideTrackBonn Sap&Adobe
 
SAP BASIS Training in Delhi in 2022
SAP BASIS Training in Delhi in 2022SAP BASIS Training in Delhi in 2022
SAP BASIS Training in Delhi in 2022
 
Abhinav_Kumar_ABAP_4 yes
Abhinav_Kumar_ABAP_4 yesAbhinav_Kumar_ABAP_4 yes
Abhinav_Kumar_ABAP_4 yes
 
Power BI 01-1.pptx
Power BI 01-1.pptxPower BI 01-1.pptx
Power BI 01-1.pptx
 
Integrating sap with web sphere portal
Integrating sap with web sphere portal Integrating sap with web sphere portal
Integrating sap with web sphere portal
 
Dell Boomi Hyderabad meetup
Dell Boomi Hyderabad meetupDell Boomi Hyderabad meetup
Dell Boomi Hyderabad meetup
 
C bu06 planning_your_cloud_education
C bu06 planning_your_cloud_educationC bu06 planning_your_cloud_education
C bu06 planning_your_cloud_education
 
Data Analytics Strategies & Solutions for SAP customers
Data Analytics Strategies & Solutions for SAP customersData Analytics Strategies & Solutions for SAP customers
Data Analytics Strategies & Solutions for SAP customers
 
Bdi Systems
Bdi SystemsBdi Systems
Bdi Systems
 
Learn why Microsoft Power BI is an Undisputed Market Leader?
Learn why Microsoft Power BI is an Undisputed Market Leader?Learn why Microsoft Power BI is an Undisputed Market Leader?
Learn why Microsoft Power BI is an Undisputed Market Leader?
 
SUSE Technical Webinar: Build B1 apps in the Framework of the SAP and SUSE Ca...
SUSE Technical Webinar: Build B1 apps in the Framework of the SAP and SUSE Ca...SUSE Technical Webinar: Build B1 apps in the Framework of the SAP and SUSE Ca...
SUSE Technical Webinar: Build B1 apps in the Framework of the SAP and SUSE Ca...
 
SAP and IBM I
SAP and IBM I SAP and IBM I
SAP and IBM I
 
C bu07 cloud_offering_decoder
C bu07 cloud_offering_decoderC bu07 cloud_offering_decoder
C bu07 cloud_offering_decoder
 
Ozone profile general presentation 1
Ozone profile general presentation 1Ozone profile general presentation 1
Ozone profile general presentation 1
 

B adi

  • 1. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Business Add-In’s November, 2003 deeper © Copyright IBM Corporation 2003 © Copyright IBM Corporation 2003 15.1 November 2003, v1
  • 2. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Lesson Objectives After completing this lesson you will be able to : Understand what Business Add In’s (BAdIs) are Define BAdIs Implement BAdIs Use BAdIs Create an implementation for an existing SAP BAdI Create Multiple Use BAdIs Create Filter Dependent BAdI 2 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 © Copyright IBM Corporation 2003 15.2 November 2003, v1
  • 3. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Introduction Traditional way of doing code modifications – Exits 3 Tier Architecture – PRESENTATION : Field Exits Screen Exits Menu Exits – APPLICATION: Programs -> Program exits -> call customer function -> Include – DATABASE Table -> SE11 -> Goto -> Append Structure With BAdIs you can make changes only at the Application Layer. 3 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • The traditional way of doing code modifications was via User exits. • As per SAP’s 3 Tier Architecture, at the Presentation layer you had Field Exits, Screen Exits and Menu Exits. At the Application layer you had Program exits, at the Database layer you could Append structures to the existing SAP structures. © Copyright IBM Corporation 2003 15.3 November 2003, v1
  • 4. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services BAdIs Business Add-Ins are a new SAP enhancement technique based on ABAP Objects They can be inserted into the SAP system based on specific user requirements 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. Each Business Add-In has : – at least one Business Add-In definition – a Business Add-In interface – a Business Add-In class that implements the interface 4 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • In order to enhance a program a Business Add-In must first be defined • Subsequently two classes are automatically generated : – An interface with ‘IF_EX_’ inserted between the first and second characters of the BAdI name – An adapter class with ‘CL_EX_’ inserted between the first and second characters of the BAdI name. • The Application developer creates an interface for this Add-In • Enhancement management generates an adapter class for implementing the interface • This opens a path for custom implementations to be created by partners or customers. • By instantiating the adapter class in the application program, its corresponding methods can be used © Copyright IBM Corporation 2003 15.4 November 2003, v1
  • 5. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services BAdI Enhancement options In Business Add-Ins, all the components of an enhancement option are grouped together – Program Enhancements: Functional enhancement of the program are defined in the form of interface methods and can be used with or without Menu Enhancements or Screen Enhancements – Menu Enhancements: Function codes can be entered for a BAdI for the corresponding menu entries in the user interface definition. – Screen Enhancements: Subscreen areas can be entered for a Business Add-In. Screen enhancements can be implemented for these in the form of subscreen screens. 5 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 © Copyright IBM Corporation 2003 15.5 November 2003, v1
  • 6. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Defining BAdIs SE18 Enter BADI name Click on CREATE 6 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • To define a BAdI use Sap Menu -> Tools -> ABAP Workbench -> Utilities -> Business Ad-Ins -> Definition • For Application developers to include BAdIs in their program they need to define an interface for their enhancement in the ‘Business Add-Ins Initial Maintenance Screen’. © Copyright IBM Corporation 2003 15.6 November 2003, v1
  • 7. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Defining BAdIs – Attributes Enter short text BADI class is automatically created 7 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • When a BAdI is created, BADI class gets automatically created with the suffix ‘CL_EX_’ after the first character of the BAdI name. • Package : Specifies the Package in which this BAdI resides. • Multiple use : With this option you can have multiple implementations for the same BAdI • Filter-Dependent : Business Add-Ins may be implemented depending on a specific filter value (example, country-specific versions: Distinct implementations of the BAdI can be created for each country). A filter type must be entered when defining your enhancement (a country or industry sector, for example). All methods created in the enhancement's interface have filter value 'FLT_VAL' as their import parameter. The method then selects the active implementation based on the data provided in the filter value © Copyright IBM Corporation 2003 15.7 November 2003, v1
  • 8. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services BADI Definition - Save Enter Package name 8 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • Save the BADI to a Package. (Z_DELTA_STUDENT##) © Copyright IBM Corporation 2003 15.8 November 2003, v1
  • 9. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Defining BAdIs Package name populated BAdI class created 9 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • A BADI class ZCL_EX_DELTA_7_0_DEMO1 is created automatically. © Copyright IBM Corporation 2003 15.9 November 2003, v1
  • 10. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Defining BAdIs - Interface BADI Interface is created automatically To edit double click on the interface 10 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • An interface is created automatically with the suffix ‘IF_EX_’ after the first character of the BAdI name • When you double click the interface ‘ZIF_EX_DELTA_7_0_DEMO1 you will be taken into the class builder where you can define the methods, parameters and exceptions for that interface © Copyright IBM Corporation 2003 15.10 November 2003, v1
  • 11. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Defining BAdIs – Interface methods Method name Method type 11 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • Specify the methods in the Class Builder for the interface • Instance methods can access all of the attributes of a class, and can trigger all of the events of the class • Static methods can only access static attributes and trigger static events • Click on the Parameters button to specify any Import/Export parameters for the method © Copyright IBM Corporation 2003 15.11 November 2003, v1
  • 12. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Defining BAdIs – Interface methods - parameters Import and Export parameters 12 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • The Import/Export parameters for the method are specified in the ‘Parameters’ section • The type specifies whether the parameter is an Importing, Exporting, Changing or Returning parameter. • Check the Optional field if it is not a mandatory parameter • The type, default value and description of the parameter can be specified © Copyright IBM Corporation 2003 15.12 November 2003, v1
  • 13. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Defining BAdIs – Exceptions Exceptions 13 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • You can specify any exceptions in the Exceptions section. • For class based exceptions, check the checkbox ‘Exception Classes’. © Copyright IBM Corporation 2003 15.13 November 2003, v1
  • 14. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services BADI Implementation SE19 Enter Implementation name Click on create Enter the BAdI Definition name 14 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • To create an implementation, proceed as follows: – Choose ABAP Workbench -> Utilities -> Business Add-Ins (transaction SE19) from the SAP menu – Enter a name for the implementation and choose Create. – Enter the name of the BAdI you want to create an implementation for in the dialog box that appears. © Copyright IBM Corporation 2003 15.14 November 2003, v1
  • 15. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services BAdI Implementation Double click on the method to modify method code 15 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • During implementation creation, a class for implementing the enhancement's interface is also created • Navigate to the Class Builder by double-clicking the method. © Copyright IBM Corporation 2003 15.15 November 2003, v1
  • 16. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Implementing BAdIs: Method implementation Modify the method code within the METHOD/ENDMETHOD statements and activate 16 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • Insert the source code between the method and endmethod statements and activated. • Exception handling for the method can be handled in this section. © Copyright IBM Corporation 2003 15.16 November 2003, v1
  • 17. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Using a BAdI 17 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • When a BAdI is created, the enhancement manager automatically generates a class that implement the interface • In order to be able to call static methods, you must declare the corresponding class in ABAP Objects using the ‘class … definition load’ statement • In the example having created a BAdI for division, you can program the call for the BAdI in the following manner: – Create an Interface Reference Variable in the program ‘L_BADI_INSTANCE’ – Perform the statement ‘call method cl_exithandler …’ using the BAdI and the interface reference variable. – Call method DIVIDE_NUMBERS using the interface reference variable L_BADI_INSTANCE. © Copyright IBM Corporation 2003 15.17 November 2003, v1
  • 18. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Create an Implementation for an SAP provided BAdI Find the corresponding BAdI for the SAP transaction Create a custom Implementation for the BAdI From the methods available in the BAdI and select the appropriate method Enter custom code in the method and activate Execute SAP transaction and test if method with custom code is being invoked 18 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 © Copyright IBM Corporation 2003 15.18 November 2003, v1
  • 19. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Finding a BAdI – Transaction VD02 Select System->Status from the drop down menu 19 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • To find a BAdI for any SAP transaction do the following: – Click on System->Status – Double click on the program name – Once inside the program search for ‘CL_EXITHANDLER=>GET_INSTANCE’. Make sure the radiobutton – In main program is checked – A list of all the programs with call to the BAdIs will be listed. – The export parameter ‘EXIT_NAME’ for the method GET_INSTANCE of class CL_EXITHANDLER will have the user exit assigned to it. – The changing parameter ‘INSTANCE’ will have the interface assigned to it. © Copyright IBM Corporation 2003 15.19 November 2003, v1
  • 20. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Finding a BAdI – Transaction VD02 Double click on the program name 20 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 © Copyright IBM Corporation 2003 15.20 November 2003, v1
  • 21. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Finding a BAdI – Source program Do a search on CL_EXITHANDLER=> GET_INSTANCE 21 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 © Copyright IBM Corporation 2003 15.21 November 2003, v1
  • 22. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Finding a BAdI – Search results Three BAdIs used in this program. Double click required BAdI to see the source code 22 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • Double click on the method to enter the source code. © Copyright IBM Corporation 2003 15.22 November 2003, v1
  • 23. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Finding a BAdI – Call to a BAdI in the source code BAdI being used Interface reference Variable for the BAdI 23 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 © Copyright IBM Corporation 2003 15.23 November 2003, v1
  • 24. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Finding a BAdI – Interface reference to the BAdI Interface reference Variable defined 24 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • If the BAdI name is not specified in the CL_EXITHANDLER=>GET_INSTANCE method call, you can find out the BAdI name by removing the prefix IF_EX_ from the interface name. © Copyright IBM Corporation 2003 15.24 November 2003, v1
  • 25. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Using an SAP BAdI – Create a Custom Implementation SE19 Enter the implementation name Click on CREATE Enter the name of the BAdI 25 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • To create a custom implementation for an SAP defined BAdI do the following: – Go to transaction SE19 – Enter a name for the BAdI – Hit the ‘Create’ button – The BAdI definition selection popup will be displayed – Enter the name of the standard SAP BADI that you want to implement © Copyright IBM Corporation 2003 15.25 November 2003, v1
  • 26. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services BAdI Implementation – Attributes Enter description 26 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • Enter the description for the custom implementation • Click on the Activate button to activate the implementation © Copyright IBM Corporation 2003 15.26 November 2003, v1
  • 27. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services BAdI Implementation – Interface methods Click on the interface tab to view the available methods Double click on method SAVE_DATA to modify it 27 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • In the interfaces tab you will find a list of methods included in the BAdI Interface • Double clicking on any of the methods will take you into the Class Builder where you can enter custom code for the corresponding method © Copyright IBM Corporation 2003 15.27 November 2003, v1
  • 28. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services BAdI Implementation – Class builder Enter custom code 28 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • In our example we have chosen the SAVE_DATA method to enter our code changes • Double clicking on the SAVE_DATA method takes us into the class builder • You can enter your code changes between the method, endmethod statements • Enter the custom code that will be executed when customer data is saved in transaction VD02. © Copyright IBM Corporation 2003 15.28 November 2003, v1
  • 29. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services BAdIs – Execute the Change customer transaction VD02 Click on SAVE button Change name of Customer 29 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • Go into the change customer transaction VD02 and change the name of the customer • Click on the SAVE button. • This should invoke the BAdI – CUSTOMER_ADD_DATA and subsequently execute the custom implementation. © Copyright IBM Corporation 2003 15.29 November 2003, v1
  • 30. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services BAdI Implementation – Invoked by VD02 Custom code for method invoked via BAdI CUSTOMER_ADD_DATA 30 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • A break point is hard-coded into the method SAVE_DATA. • Execute transaction VD02 and change the customer address. • When you hit the SAVE button, the code entered in the SAVE_DATA method is executed. © Copyright IBM Corporation 2003 15.30 November 2003, v1
  • 31. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Multiple Use BAdIs Single Use Business Add-Ins Multiple Use Business Add-Ins – Do NOT select the Multiple use checkbox – Select the Multiple use checkbox from from the Administration tab when defining the Administration tab when creating the a Single Use BAdI BAdI definition – BAdI has a single Implementation – BAdI has multiple implementations – Similar to procedures – Similar to event calls – Return values can be expected – Cannot expect return values – Can use importing, changing and – Can use importing and changing returning parameters parameters – N/A – For multiple implementations there is no sequence control because at the time of BAdI definition it does not know which implementation will be active – A single implementation will be triggered – All active implementations will be by the application program triggered by the application program using the BAdI 31 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 © Copyright IBM Corporation 2003 15.31 November 2003, v1
  • 32. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Multi Use BAdIs – CUSTOMER_ADD_DATA Definition SAP defined BAdI – CUSTOMER_ADD_DATA Multiple use Button checked 32 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • CUSTOMER_ADD_DATA is an SAP defined BAdI that is invoked by the transaction VD02 © Copyright IBM Corporation 2003 15.32 November 2003, v1
  • 33. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Multi Use BAdIs – Custom Implementation for BAdI – CUSTOMER_ADD_DATA Create a second implementation for BAdI CUSTOMER_ADD_DATA Click on CREATE Specify BAdI name 33 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • Create a second implementation for BAdI CUSTOMER_ADD_DATA © Copyright IBM Corporation 2003 15.33 November 2003, v1
  • 34. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Multi Use BAdIs – Interface method SAVE_DATA Double click on method SAVE_DATA 34 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • Double click on method SAVE_DATA TO enter the class builder where you can enter custom code for this method. © Copyright IBM Corporation 2003 15.34 November 2003, v1
  • 35. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Multi Use BAdIs – Modify method SAVE_DATA Enter custom code for method SAVE_DATA 35 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • Enter the custom code for the method SAVE_DATA in the class builder and activate. • Activate the BAdI Implementation before exiting. © Copyright IBM Corporation 2003 15.35 November 2003, v1
  • 36. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Multi Use BAdIs – View implementations for BAdI SE18 Select to display list of Implementations for BAdI CUSTOMER_ADD_DATA Displays list of Implementations 36 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • To view all implementation for BAdi CUSTOMER_ADD_DATA go to the BAdI definition in se18. Click on Implementation->Display. • A list of all the Implementations is displayed. • You can CREATE, CHANGE, DISPLAY and DELETE Implementations from here. • Both BAdIs will be triggered when the customer data is modified in transaction VD02 and saved. © Copyright IBM Corporation 2003 15.36 November 2003, v1
  • 37. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Filter Dependent BAdIs Business Add-Ins can be implemented based on a specific filter value If you want to call the implementation of a Business Add-In depending not only on one filter value but on various values, you can enter the name of a structure into the Filter type field. The structure can consist of several data elements that fulfill the above conditions for data elements 37 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 © Copyright IBM Corporation 2003 15.37 November 2003, v1
  • 38. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Filter Dependent BAdIs – BAdI Definition SE18 Click checkbox for Filter Dependent BAdIs Enter Filter type 38 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • A filter type can be a data element or a structure. A data element must fulfill the following criteria: – The data element's domain may contain a maximum of 30 characters and must be of type Character. – The data element must 1). either have a search help with a search help parameter of the same type as the data element and this parameter must serve as both the import and export parameter or 2). the element's domain must have fixed domain values or a value table containing a column with the same type as the data element. © Copyright IBM Corporation 2003 15.38 November 2003, v1
  • 39. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Filter Dependent BAdIs – BAdI Definition Enter text Double click on the Interface to add parameters and methods 39 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • When you double click on the interface it takes you to the class builder where you can add methods, parameters, and exceptions to the interface. © Copyright IBM Corporation 2003 15.39 November 2003, v1
  • 40. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Filter Dependent BAdIs – Interface - Method Definition 40 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • Now create an interface with a method. Be aware that for each method you create in the interface of a filter-dependent enhancement, the appropriate filter value must be defined as the import parameter so that the application program can provide the filter value to the enhancement method. The method then selects the active implementation for that value. © Copyright IBM Corporation 2003 15.40 November 2003, v1
  • 41. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Filter Dependent BAdIs – Interface – Parameter Definition Create parameter to export tax rate FLT_VAL parameter preset for method 41 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • The filter value is declared using parameter flt_val and is preset in the list of parameters. © Copyright IBM Corporation 2003 15.41 November 2003, v1
  • 42. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Filter Dependent BAdIs – Implementation Create BAdI Implementation Select CREATE button Enter name of BAdI 42 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 © Copyright IBM Corporation 2003 15.42 November 2003, v1
  • 43. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Filter Dependent BAdIs – BAdI Implementation SE19 Click on button to create an entry for filter value Select a value from the search help or enter a valid value 43 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • Create a BAdI © Copyright IBM Corporation 2003 15.43 November 2003, v1
  • 44. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Filter Dependent BAdIs – BAdI Implementation Select the Interface tab Double click on the Method to enter source code 44 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 © Copyright IBM Corporation 2003 15.44 November 2003, v1
  • 45. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Filter Dependent BAdIs – Method code Save and activate Enter code for the Method to calculate the tax rate based on the company code in Parameter FLT_VAL 45 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • The parameter FLT_VAL will have the company code value passes to the implementation. • Move the tax rate to the export parameter Z_TAX_RATE. • Save and Activate the method © Copyright IBM Corporation 2003 15.45 November 2003, v1
  • 46. SAP Development 4.0 to 6.20 Delta Training BAdIs Business Consulting Services Filter Dependent BAdIs – Source code to Invoke BAdI Selection screen parameter for Company code Call BADI from within the program Call method get_bukrs passing the company code The Tax rate is returned 46 ABAP | Confidential | 15_BAdl v1 .ppt | 10/29/2003 © Copyright IBM Corporation 2003 • A second implementation can be created wherein a different set of company codes can be specified. © Copyright IBM Corporation 2003 15.46 November 2003, v1