Step by Step Guide on BADI Multiple Use Implementation

Embed Size (px)

Citation preview

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    1/36

    http://careerabap.blogspot.in/2011/02/step-by-step-

    guide-on-badi-multiple-use.html

    Step by Step guide on BADI Multiple use implementationEmail ThisBlogThis!Share to TwitterShare to Facebook

    Step 1 Enter a BADI Definition name and Click on the CREATE button.

    Enter a short description and under the TYPE section choose if you wish to have multiple implementation

    or a Filter object to the BADI.

    See F1 help on the multiple use and Filter to find more details

    http://careerabap.blogspot.in/2011/02/step-by-step-guide-on-badi-multiple-use.htmlhttp://careerabap.blogspot.in/2011/02/step-by-step-guide-on-badi-multiple-use.htmlhttp://www.blogger.com/share-post.g?blogID=6991746904176855573&postID=4267121302869267003&target=emailhttp://www.blogger.com/share-post.g?blogID=6991746904176855573&postID=4267121302869267003&target=bloghttp://www.blogger.com/share-post.g?blogID=6991746904176855573&postID=4267121302869267003&target=bloghttp://www.blogger.com/share-post.g?blogID=6991746904176855573&postID=4267121302869267003&target=twitterhttp://www.blogger.com/share-post.g?blogID=6991746904176855573&postID=4267121302869267003&target=twitterhttp://www.blogger.com/share-post.g?blogID=6991746904176855573&postID=4267121302869267003&target=facebookhttp://www.blogger.com/share-post.g?blogID=6991746904176855573&postID=4267121302869267003&target=facebookhttp://careerabap.blogspot.in/2011/02/step-by-step-guide-on-badi-multiple-use.htmlhttp://careerabap.blogspot.in/2011/02/step-by-step-guide-on-badi-multiple-use.htmlhttp://www.blogger.com/share-post.g?blogID=6991746904176855573&postID=4267121302869267003&target=emailhttp://www.blogger.com/share-post.g?blogID=6991746904176855573&postID=4267121302869267003&target=bloghttp://www.blogger.com/share-post.g?blogID=6991746904176855573&postID=4267121302869267003&target=twitterhttp://www.blogger.com/share-post.g?blogID=6991746904176855573&postID=4267121302869267003&target=facebook
  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    2/36

    Click on Save and create a TP

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    3/36

    Step 2 Define the Interface

    Use the menu GOTO INTERFACE or simply double click on the interface name under the interface

    tab.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    4/36

    Enter the method name and define the methods parameters in the interface.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    5/36

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    6/36

    Click on Save and return back to the initial screen.

    Follow the steps above to enter more methods if you wish too.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    7/36

    Parameters for the second method.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    8/36

    Click on save and activate to activate the custom BADI.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    9/36

    If there is any inconsistencies in the BADI definition and the interface definition the system will throw a

    warning message as shown below

    Based on the selection the system will automatically adjust the BADI definition or interface.

    In our case the system adjusted the parameters for the methods. It changed the Exporting parameter to

    the Changing parameters

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    10/36

    Step 3 Create the Implementation for the BADI. You can either go to TCode SE19 or use the menu

    option Implementation Create as shown in the screen shot below.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    11/36

    Enter the name of the BADI implementation you wish to create and click on the continue button.

    On the next screen enter a description for the implementation and click on the save button and create TP

    subsequently.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    12/36

    Click on the interface tab

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    13/36

    And double click on the method you wish to implement in the current BADI implementation. Write the

    code to achieve the functionality of the method.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    14/36

    Click on the execute button to test the method.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    15/36

    On the next screen click on the Edit Interface view button or the display icon next to the ZIF_EX_MYBADI

    node.

    Now click on the execute button against the method to execute the functionality.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    16/36

    Enter the required parameters and click on execute to see the results or the output or the outcome of the

    method execution.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    17/36

    Similarly finish the coding for the other methods.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    18/36

    Once done do the testing and see if it works fine

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    19/36

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    20/36

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    21/36

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    22/36

    Once the testing is done. Return to the main screen and activate the implementation of the BADI.

    So far what we have seen is only ONE IMPLEMENTATION of the BADI. We have not done MULTIPLE

    IMPLENTATION so far. We will now proceed to write a simple program.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    23/36

    As seen above the program is very simple and has the following components.

    1. Data declaration (Type ref and any other data variables as required)

    2. Call to the method CL_EXITHANDLER to get the implementation name of the BADI

    3. Using the instance, call the method which has been implemented for the BADI.

    To call the method you can use the PATTERN option as shown below from the ABAP editor.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    24/36

    Do a CTRL + F6 to get the pattern button or click on the PATTERN button from the application tool bar.

    Select the ABAP OBJECT patterns radiobutton and click on the continue button.

    On the next screen enter the class name and the method to be called as shown below

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    25/36

    It does not matter whether you are calling the static method or the instance method. Click on the continue

    button.

    Make changes as required and pass the respective parameters. In the above case we changed the

    EXIT_NAME and the INSTANCE parameters.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    26/36

    Now call the method from the interface using the interface reference l_BADI_INSTANCE as shown below

    Enter the parameters required and any additional code required for the report.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    27/36

    Run the report and you will get the output as shown below

    Now lets go back and create a new IMPLEMENTATION in SE19 as we have enabled MULTIPLE USE in

    the BADI DEFINITION.

    Go to SE19 and enter a new name and click on the create button

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    28/36

    And when asked for the definition enter the same definition name.

    And click on the continue button.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    29/36

    Enter a meaningful description and save and activate the second implementation. Next double click onthe method you wish to implement and write the code.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    30/36

    As seen above in the second implementation we have hard coded the value for the email id instead of

    getting the value from the tables. Save and activate the method and then return to the main screen and

    activate the implantation again.

    Now try to go to each of the implementation and place a breakpoint at the methods. So we first go to the

    implementation 1 and place a break point as shown below.

    And similarly go to the second implementation and place a breakpoint on the method as shown below

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    31/36

    Once done. Go to SE38 and execute the program developed in earlier steps. You will notice that the

    program will stop at both the breakpoints as the system triggers all the implementations if there is more

    than one for a multiple use BADI.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    32/36

    Now if you check the value of the variable emailed then you will notice that the emailed is fetched from

    the database.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    33/36

    Now click F7 till you reach to the next breakpoint or the next implementation

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    34/36

    So if you see from the above screen. The cursor is at the second implementation and the value of the

    email-id is still available in the second implementation.

    Now if you execute one step, the value of email-id will be overwritten as shown below.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    35/36

    And once you execute completely you get the output of the report.

  • 7/30/2019 Step by Step Guide on BADI Multiple Use Implementation

    36/36

    PLEASE NOTE: in our case the system first executed the FIRST BADI IMPLEMENTATION and later itexecuted the SECOND BADI IMPLENETATION. However this sequence is dynamic and there is noguarantee that this sequence will be maintained all the time.