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 and implement badi's

Former Member
0 Kudos

hello can any one tell me how to find badi's for a transaction and implement them if any one can show with example will be helpful if any of standard transaction for sd ,

regards

afzal

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Check theses threads -

ashish

4 REPLIES 4

Former Member
0 Kudos

Hi,

Just copy and paste this code in editor and execute it.

Then give your Transaction coe it will displays all user exits Regrading your T.Code.

*&---------------------------------------------------------------------*

*&  Enter the transaction code that you want to search through in order

*&  to find which Standard SAP User Exits exists.

*&

*&---------------------------------------------------------------------*



*&---------------------------------------------------------------------*

*& Tables

*&---------------------------------------------------------------------*



TABLES : tstc,     "SAP Transaction Codes

         tadir,    "Directory of Repository Objects

         modsapt,  "SAP Enhancements - Short Texts

         modact,   "Modifications

         trdir,    "System table TRDIR

         tfdir,    "Function Module

         enlfdir,  "Additional Attributes for Function Modules

         tstct.    "Transaction Code Texts



*&---------------------------------------------------------------------*

*& Variables

*&---------------------------------------------------------------------*



DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE.

DATA : field1(30).

DATA : v_devclass LIKE tadir-devclass.



*&---------------------------------------------------------------------*

*& Selection Screen Parameters

*&---------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK a01 WITH FRAME TITLE text-001.

SELECTION-SCREEN SKIP.

PARAMETERS : p_tcode LIKE tstc-tcode OBLIGATORY.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN END OF BLOCK a01.



*&---------------------------------------------------------------------*

*& Start of main program

*&---------------------------------------------------------------------*



START-OF-SELECTION.



* Validate Transaction Code

  SELECT SINGLE * FROM tstc

    WHERE tcode EQ p_tcode.



* Find Repository Objects for transaction code

  IF sy-subrc EQ 0.

    SELECT SINGLE * FROM tadir

       WHERE pgmid    = 'R3TR'

         AND object   = 'PROG'

         AND obj_name = tstc-pgmna.



    MOVE : tadir-devclass TO v_devclass.



    IF sy-subrc NE 0.

      SELECT SINGLE * FROM trdir

         WHERE name = tstc-pgmna.



      IF trdir-subc EQ 'F'.



        SELECT SINGLE * FROM tfdir

          WHERE pname = tstc-pgmna.



        SELECT SINGLE * FROM enlfdir

          WHERE funcname = tfdir-funcname.



        SELECT SINGLE * FROM tadir

          WHERE pgmid    = 'R3TR'

            AND object   = 'FUGR'

            AND obj_name = enlfdir-area.



        MOVE : tadir-devclass TO v_devclass.

      ENDIF.

    ENDIF.



* Find SAP Modifactions

    SELECT * FROM tadir

      INTO TABLE jtab

      WHERE pgmid    = 'R3TR'

        AND object   = 'SMOD'

        AND devclass = v_devclass.



    SELECT SINGLE * FROM tstct

      WHERE sprsl EQ sy-langu

        AND tcode EQ p_tcode.



    FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.

    WRITE:/(19) 'Transaction Code - ',

    20(20) p_tcode,

    45(50) tstct-ttext.

    SKIP.

    IF NOT jtab[] IS INITIAL.

      WRITE:/(95) sy-uline.

      FORMAT COLOR COL_HEADING INTENSIFIED ON.

      WRITE:/1 sy-vline,

      2 'Exit Name',

      21 sy-vline ,

      22 'Description',

      95 sy-vline.

      WRITE:/(95) sy-uline.



      LOOP AT jtab.

        SELECT SINGLE * FROM modsapt

        WHERE sprsl = sy-langu AND

        name = jtab-obj_name.

        FORMAT COLOR COL_NORMAL INTENSIFIED OFF.

        WRITE:/1 sy-vline,

        2 jtab-obj_name HOTSPOT ON,

        21 sy-vline ,

        22 modsapt-modtext,

        95 sy-vline.

      ENDLOOP.



      WRITE:/(95) sy-uline.

      DESCRIBE TABLE jtab.

      SKIP.

      FORMAT COLOR COL_TOTAL INTENSIFIED ON.

      WRITE:/ 'No of Exits:' , sy-tfill.

    ELSE.

      FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.

      WRITE:/(95) 'No User Exit exists'.

    ENDIF.

  ELSE.

    FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.

    WRITE:/(95) 'Transaction Code Does Not Exist'.

  ENDIF.



* Take the user to SMOD for the Exit that was selected.

AT LINE-SELECTION.

  GET CURSOR FIELD field1.

  CHECK field1(4) EQ 'JTAB'.

  SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).

  CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.

Thanks,

Reward If Helpful.

Former Member
0 Kudos

Check theses threads -

ashish

Former Member
0 Kudos

Hi,

You can use this way also,

To find badis for any transactions --->

1. Go to Transaction SE24

2. Enter the Object Type CL_EXITHANDLER and click on Display.

3. Double Click on method "GET_INSTANCE".

4. Put a Break-point on

Call method cl_exithandler=>get_class_name_by_interface

5. Run any Transaction for which you need enhancements.

6. The execution will stop at the break point. Check the values of variable 'exit_name', it will give you the BADI name called at that time.

Thanks,

Reward If Helpful.

Former Member
0 Kudos

Hi Mohammed,

Yes,you are asking the query in a reverse order.

Actually,for every T-code,SAP has provided a lot of BADIs where the customer can write their own codes depending upon the functionality required.

In order to find the BAD for a particular T-code,go to the T-code SE24 and type in cl_exithandler and click on Display.

You will get a list of methods in that class,double click on the Get_Instance method from the list.

you will get the code for that method.Scroll down and you will find one of the parameters "Exit Name" there.Put a breakpoint on that function module and press F8.

In the debugging mode,double click on the Exit Name to get the value contained in it.You will see the first BADI provided in that T-code.

Note down this and then keep on pressng the F8 and noting down the BADIs being displayed.

Now ,you will have to find out the BADI which fits your requirement.

Now,it is not required to opy that BADI into ZBADI.Instead it is better to create a new implementation for this BADI.

Go to the T-code SE18 and see its definition.

Now,go to the T-code SE19 and create a new implementation and write the code there.

Once done,activate that implementation and the BADI also.

Now run the T-code and debug the code that you have written.You can modify the code accordng to your requirements.

In case you have any further clarifications,do let me know.

Regards,

Puneet Jhari.