Skip to Content

This document gives the step by step method for implementing BADI for user exit variables in Bex. This is an alternative approach to adding the code in EXIT_SAPLRRS0_001 through CMOD.

Writing codes for user exits in CMOD exit makes it cumbersome and difficult to debug. Besides, if multiple users want to write the code for user exits at the same time, they can’t do so. To overcome this, we can create BADI implementations in Enhancement spot and write a code to call the BADI in EXIT_SAPLRRS0_001.

Go to transaction SE18 and create an enhancement Spot as shown below

/wp-content/uploads/2012/08/badi_132628.jpg

Enter description in short text and hit enter

/wp-content/uploads/2012/08/badi_132628.jpg

Create BADI definition

/wp-content/uploads/2012/08/badi_132628.jpg

Enter a technical name and description for Badi definition and hit enter

/wp-content/uploads/2012/08/badi_exit_132619.jpg

Select the option for multiple use and create filter as shown below

/wp-content/uploads/2012/08/badi_132628.jpg

Give a technical name and description for the filter and maintain settings as shown below

/wp-content/uploads/2012/08/badi_132628.jpg

Before creating the filter, dictionary object ZGLOB_VAR needs to be defined through SE11. ZVAR_NAM is a domain object we created with data type as char and length 30 which should be sufficient to hold the technical name of the variable.

/wp-content/uploads/2012/08/badi_132628.jpg

Next, we need to create interface by entering technical name and clicking on change.

/wp-content/uploads/2012/08/badi_132628.jpg

Select level as Instance Method and give a name to method and description

/wp-content/uploads/2012/08/badi_132628.jpg 

Under properties tab, enter type groups you need and keep the other tabs unchanged

/wp-content/uploads/2012/08/badi_132628.jpg

With this, enhancement spot definition is complete. Next, we create individual implementation for each user exit variable. An e.g is shown below.

/wp-content/uploads/2012/08/badi_132628.jpg

Enter technical name and description and hit enter

/wp-content/uploads/2012/08/badi_132628.jpg

Next, we create Badi implementation and Implementing Class for the enhancement

/wp-content/uploads/2012/08/badi_132628.jpg

The implementation is created. Then, customer exit variable name needs to be assigned to the filter and the corresponding code should be entered in the method of implementing class.

/wp-content/uploads/2012/08/badi_132628.jpg 

Click on filter val and select new combination as shown below

/wp-content/uploads/2012/08/badi_132628.jpg

Click on the combination 1 and assign the technical name (ZFDAY in our case) of the customer exit variable to the filter

/wp-content/uploads/2012/08/badi_132628.jpg

/wp-content/uploads/2012/08/badi_132628.jpg

Then we need to click on Implementing Class, select the method on the right side and say yes

/wp-content/uploads/2012/08/badi_132628.jpg

Enter your code in the space

/wp-content/uploads/2012/08/badi_132628.jpg

On activation, we will have completed our first implementation. Like this, we can keep adding implementations as and when we create customer exit variables.

/wp-content/uploads/2012/08/badi_132628.jpg

In the include of EXIT_SAPLRRS0_001 of our enhancement project in CMOD, we need to add a code to call the BADI as given below

DATA: badi_glob TYPE REF TO ZBW_VAR_BADI_EXIT.

GET BADI badi_glob

  FILTERS

    zglob_var = i_vnam.

CALL BADI badi_glob ->enhance

  EXPORTING

    flt_val       = i_vnam   

    i_vnam        = i_vnam

    i_vartyp      = i_vartyp

    i_iobjnm      = i_iobjnm

    i_s_cob_pro   = i_s_cob_pro

    i_s_rkb1d     = i_s_rkb1d

    i_periv       = i_periv

    i_t_var_range = i_t_var_range

    i_step        = i_step

  CHANGING

    e_t_range     = e_t_range

    e_meeht       = e_meeht

    e_mefac       = e_mefac

    e_waers       = e_waers

    e_whfac       = e_whfac

    c_s_customer  = c_s_customer.

To report this post you need to login first.

14 Comments

You must be Logged on to comment or reply to a post.

  1. Hari Krishna

    Hello….

    Explicitly written and cleared the air for me on BADI. Could you please post a document on ”How to pass two variable for BADI implementaion”…..Its invariably appreciated…

    Regards,

    HariKrishna

    (0) 
  2. anirban mukhopadhyay

    Hi Blasco,

    Thanks for this. But, would it work in an SAP BW 7.0 system?

    I am facing an error at the i_step declaration point.

    Any help is appreciated.

    Guys,

    Any idea on this?

    Thanks!

    Anirban

    (0) 
    1. Loed Despuig

      Hi,

      I’m also experiencing the same problem as anirban mukhopadhyay..Did I miss some config?


      /wp-content/uploads/2016/02/delete_887664.jpg

      Also, do I need to apply this in the INCLUDE ZXRSRU01 of FUNCTION EXIT_SAPLRRS0_001?

      DATA: badi_glob TYPE REF TO ZBW_VAR_BADI_EXIT.

      GET BADI badi_glob

        FILTERS

          zglob_var = i_vnam.

      CALL BADI badi_glob ->userexit

        EXPORTING

          flt_val       = i_vnam  

          i_vnam        = i_vnam

          i_vartyp      = i_vartyp

          i_iobjnm      = i_iobjnm

          i_s_cob_pro   = i_s_cob_pro

          i_s_rkb1d     = i_s_rkb1d

          i_periv       = i_periv

          i_t_var_range = i_t_var_range

          i_step        = i_step

        CHANGING

          e_t_range     = e_t_range

          e_meeht       = e_meeht

          e_mefac       = e_mefac

          e_waers       = e_waers

          e_whfac       = e_whfac

          c_s_customer  = c_s_customer.

      Thank you.

      Loed

      (0) 
  3. swati gawade

    Hi,

    When I’m entering this code in CMOD I’m getting error “Method “ENHANCE” is unknown or PROTECTED or PRIVATE.  ” Can you please help?

    Thanks,

    Swati.

    (0) 

Leave a Reply