Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to find the place to write the code for a BAdI?

Former Member
0 Kudos

Hi ,

I am clear of BAdI Definition and Implementation. Not sure of the place where to do the coding in the standard program. Will there be any points like user exits(or enhancements). Also I am clear of SMOD/CMOD concepts.

Prior to asking this question I did so much of research in this fourm. I could not able to find the corrrect answer.

May be I am compring this concept with user exits(or enhancements). Please give some light on this topic. Thanks in advance.

Thank you,

Surya.

1 ACCEPTED SOLUTION

aidaj_hilton
Participant
0 Kudos

Hi Surya,

To find where the BAdI is called in a program you do a search in the program for cl_exithandler*

This will return all the instances in the program where this class is referenced.

For example: I did this search in the program for transaction MIGO

Returned a number of instances where this class is referenced:

CALL METHOD cl_exithandler=>get_instance

EXPORTING

exit_name = 'BADI_SERIAL_IN_STO'

....

CHANGING

instance = lp_badi_serial_in_sto

...

double-click on the variable lp_badi_serial_in_sto and this will take you to the definition. This variable is defined with ref to a class if_ex_badi_serial_in_sto.

You can then go to transaction SE18 and enter the BADI if_ex_badi_serial_in_sto and read up on the documention for this particular BADI.

If you are on ECC6 and have access to the new BAdI's these can be found by doing a search in the program for the statement GET BADI*

Hope this answers your question.

Edited by: Jill Hilton on Feb 6, 2009 1:57 AM

Edited by: Jill Hilton on Feb 6, 2009 1:58 AM

9 REPLIES 9

Former Member
0 Kudos

HI,

Refer to this Link..

[Implementing Business Add-Ins (BADI)|http://www.sapdevelopment.co.uk/enhance/enhance_badi.htm]

[Step by step screen shots|http://genieholdings.com/erpgenie/abap/tips/badi.htm]

[Implementing a BAdI in an Enhancement Project (CMOD)|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d0456c54-0901-0010-f0b3-cd765fb99702]

Edited by: Avinash Kodarapu on Feb 5, 2009 9:47 AM

Former Member
0 Kudos

Hi,

In BADI first you have to implement throgh SE19.

Then Open the Methods.

By Seeing the parameters in the method you can understand that which methods will suits you.

Regards

Sandipan

Former Member
0 Kudos

Hi Surya,

BADI's are provided by SAP to enhance the standard/existing functionality.

In case of User exits the codes have to be written in Modules provided in Includes. But the codes pertaining to a BADI are written in the methods of the BADI implementation.

In case of User exits different modules are called at different/specific times/instances.

Similarly in case of a BADI different methods are called at different/specific times/instances. All methods of the BADi are not called at once. View the documentation provided by SAP for a BADI to know when a particular method of the BADI is being trigerred.

First create an implementation of the requisite BADI definition. Then double click on the requisite method. This will open up the editor. Write your code for that method . Save and activate. Als activate the BADI implementation.

You BADI method will now be called from the standard program.

Hope the above information helps.

Regards,

Abhisek.

0 Kudos

Hi Avinash, Sandipan, Abhisek,

Thanks for your reply. As I mentioned already I am clear of BAdI definition and Implementation, coding methods etc.

Abhisek: My question is close to your statement. You mentioned that

You BADI method will now be called from the standard program

How to know from where this call is made in the standard program?

I saw the following example also. I am really confused why this created add-in class used in the report program?

Is this report being called from the SAP standard program (like VA01) ?

http://help.sap.com/saphelp_nw04/helpdata/en/eb/3e7cf4940e11d295df0000e82de14a/frameset.htm

Thank you,

Surya.

Edited by: Surya on Feb 5, 2009 1:24 PM

0 Kudos

Hi Surya,

To know the position in a standard code from which a BADI is called, you can search the code with the string CALL BADI. CALL BADI is used to call a BADI method.

Also if CL_EXITHANDLER is used to get the instance then GET METHOD is used to call a BADI method.

I think that you already know a BADI name and its methods and you are trying to search the standard code from which it is being called.

But the flow should be that you should first know which transaction/code needs to be enhanced. Then the requisite BADI has to be found using the methods suggested by Bala Krishna and Jill Hilton .

The example:


Having created a string conversion Business Add-In, you would program the call of the Business Add-In into your ABAP source code as follows:

1    Report businessaddin.
2    class cl_exithandler definition load.           "Declaration
3    data exit type ref to if_ex_businessaddin.      "Interface reference
4    data word(15) type c value 'Business Add-in'.   "String to change

5    start-of-selection.
6      call method cl_exithandler=>get_instance      "Factory method call
7            exporting                                                "Method
                exit name              =u2019BUSINESSADDINu2019
8              null instance accepted =u2019Xu2019
9            changing instance = exit.
10     write:/'Please click here'.

11   at line-selection.
12     write:/ 'Original word: ',word.

13   if not exit is initial.
14     call method exit->method                    "Add-In call
15           changing parameter = word.
16   endif.
17     write:/ 'Original word: ',word.

is provided in help.sap.com just to illustrate how a BADI method may be called. Similar type of code is also present in standard codes to call a BADI method. And no the above report is not being called from any standard transaction.

If you refer to inlcude LMEGUICIM of program SAPLMEGUI you can find the below mentioned piece of code:


*     BAdI 'ME_CATALOG_INTERFACE' to determine field mapping
      TRY.
          REFRESH lt_map_fields.
          GET BADI l_badi.
          l_item_descr ?= cl_abap_structdescr=>describe_by_data(
                                                 ls_cat_item ).
          l_catalog_descr ?= cl_abap_structdescr=>describe_by_data(
                                                    ls_oci_item ).
          CLEAR ls_map_fields.
          CALL BADI l_badi->map_cat_values
            EXPORTING
              im_bstyp                   = 'F'
              im_catalog_structure       = 'ls_oci_item'
              im_catalog_structure_descr = l_catalog_descr
              im_item_structure          = 'ls_cat_item'
              im_item_structure_descr    = l_item_descr
            IMPORTING
              ex_field_map               = lt_map_fields
            CHANGING
              ch_oci_item                = ls_oci_item.
        CATCH cx_badi_not_implemented.
*         nothing
      ENDTRY.

Also if you have a look at the Function Module MEPOBADI_INITIALIZE you can see the following code:


 CALL METHOD l_instance_ibs->initialize( ).

The BADI methods are called from standard programs using the two methods illustrated above.

Hope this helps.

Regards,

Abhisek.

former_member585060
Active Contributor
0 Kudos

Hi,

Goto SE37 and give function module name SXV_GET_CLIF_BY_NAME,

Now got to the transaction to which you want to implement a BADI,

Input all the values, and go to the corresponding Tab in the Tcode,where you want to implement the BADI,

In SE37 for above said FM put a break point.

In the transaction Tab, input the values and click on next tab,

it will take you to the Debugger of the Aabove said FM, now

Note the value of the NAME it will show the BADI name at that corresponding tab in the Tcode

Click F8, it will stop at another BADI if it has, if not it goes to next Tab,

like wise you can find out all the BADI at corresponding Tabs, by putting the breakpoint in the FM.

note : keep break point only after you go to the required tab, or else it will stop at each and every BADI for that transaction.

Regards

Bala Krishna.

aidaj_hilton
Participant
0 Kudos

Hi Surya,

To find where the BAdI is called in a program you do a search in the program for cl_exithandler*

This will return all the instances in the program where this class is referenced.

For example: I did this search in the program for transaction MIGO

Returned a number of instances where this class is referenced:

CALL METHOD cl_exithandler=>get_instance

EXPORTING

exit_name = 'BADI_SERIAL_IN_STO'

....

CHANGING

instance = lp_badi_serial_in_sto

...

double-click on the variable lp_badi_serial_in_sto and this will take you to the definition. This variable is defined with ref to a class if_ex_badi_serial_in_sto.

You can then go to transaction SE18 and enter the BADI if_ex_badi_serial_in_sto and read up on the documention for this particular BADI.

If you are on ECC6 and have access to the new BAdI's these can be found by doing a search in the program for the statement GET BADI*

Hope this answers your question.

Edited by: Jill Hilton on Feb 6, 2009 1:57 AM

Edited by: Jill Hilton on Feb 6, 2009 1:58 AM

0 Kudos

Thank you all !

Jil Hilton's message is what I am looking for. Full points are awarded to him.

Thank you,

Surya

Former Member
0 Kudos

Hi,

check below link

https://www.sdn.sap.com/irj/sdn/advancedsearch?query=howtoimplement+badi&cat=sdn_all

Regards,

Madhu