For finding the BADI: put a break point in CL_EXITHANDLER class’s GET_INSTANCE Method and execute the Transaction code whenever it call a BADI debugger stops at that points.
Advantage: It is for sure that you will get the respective BADI.
Disadvantage: It is not possible to get USER-EXIT or kernel BADI (As Kernel BADI is using GET BADI syntax to get the instance of its class)
This is the most commonly used option: Get the package in which the transaction code belongs and open that package in SE80:
Here you will get all that you need but it is very difficult to identify the perfect user EXIT or BADI.
Try out the Below Report Program: Give a Transaction Code as an input and it will return you ALL the User EXIT and BADI which can be used.
*&———————————————————————*
*& Report zget_badi_exit
*&———————————————————————*
*&
*&
*&———————————————————————*
REPORT zget_badi_exit.
TABLES : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir, sxs_attrt , tstct.
DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE.
TYPES : BEGIN OF stab ,
include
TYPE tadir ,
txt(60) TYPE c,
END
OF stab.
DATA : it_tab TYPE STANDARD TABLE OF stab.
DATA : wa_tab LIKE LINE OF it_tab.
DATA : field1(30).
DATA : v_devclass LIKE tadir-devclass.
DATA : it_badi_spot TYPE STANDARD TABLE OF badi_spot.
DATA : wa_badi_spot LIKE LINE OF it_badi_spot.
PARAMETERS : p_tcode LIKE tstc-tcode,
p_pgmna LIKE tstc-pgmna .
DATA: otr_context TYPE sotr_cntxt,
otr_text TYPE sotr_text,
otr_key TYPE sotr_key.
DATA wa_tadir TYPE tadir.
START-OF-SELECTION.
IF NOT p_tcode IS INITIAL.
SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode.
ELSEIF
NOT p_pgmna IS INITIAL.
tstc-pgmna = p_pgmna.
ENDIF.
IF sy-subrc EQ 0.
SELECT SINGLE * FROM tadir into wa_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 EQ enlfdir-area.
MOVE : tadir-devclass TO v_devclass.
ENDIF.
ENDIF.
SELECT * FROM tadir INTO table jtab
WHERE pgmid = ‘R3TR’ AND object IN (‘SMOD’, ‘SXSD’)
AND devclass = v_devclass.
SELECT SINGLE * FROM tstct WHERE sprsl EQ sy-langu
AND tcode EQ p_tcode.
*Get Kernal BADIS
SELECT * FROM badi_spot AS a INNER JOIN enhspotheader AS b
ON a~enhspotname EQ b~enhspot INNER JOIN tadir AS c
ON a~enhspotname EQ c~obj_name INTO CORRESPONDING FIELDS OF
TABLE it_badi_spot WHERE c~pgmid EQ ‘R3TR’ AND c~object EQ ‘ENHS’
AND c~devclass EQ v_devclass.
IF sy-subrc EQ 0.
loop at it_badi_spot into wa_badi_spot.
move wa_badi_spot-BADI_NAME to wa_tadir-OBJ_NAME.
move ‘ENHS’ to wa_tadir-object.
append wa_tadir to jtab.
ENDLOOP.
ENDIF.
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:/(105) sy-uline.
FORMAT COLOR COL_HEADING INTENSIFIED
ON.
* Sorting the internal Table
SORT jtab BY object.
DATA : wf_txt(60) TYPE c,
wf_smod TYPE i ,
wf_badi TYPE i ,
wf_object2(30) TYPE c.
CLEAR : wf_smod, wf_badi , wf_object2.
* Get the total SMOD.
IF jtab[] IS NOT INITIAL.
FORMAT COLOR 2 INTENSIFIED ON.
WRITE : / ‘Click on the USER EXIT or BADI to VIEW/EDIT’.
ENDIF.
LOOP AT jtab INTO wa_tadir.
AT FIRST.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/1 sy-vline, 2 ‘Enhancement/ Business Add-in’,
41 sy-vline , 42 ‘Description’, 105 sy-vline.
WRITE:/(105) sy-uline.
ENDAT.
CLEAR wf_txt.
AT NEW object.
IF wa_tadir-object = ‘SMOD’.
wf_object2 = ‘Enhancement’ .
ELSEIF wa_tadir-object = ‘SXSD’.
wf_object2 = ‘ Business Add-in’.
ELSEIF wa_tadir-object = ‘ENHS’.
wf_object2 = ‘ Kernal Business Add-in’.
ENDIF.
FORMAT COLOR COL_GROUP INTENSIFIED ON.
WRITE:/1 sy-vline, 2 wf_object2, 105 sy-vline.
ENDAT.
CASE wa_tadir-object.
WHEN ‘SMOD’.
wf_smod = wf_smod + 1.
SELECT SINGLE modtext INTO wf_txt FROM modsapt
WHERE sprsl = sy-langu
AND name = wa_tadir-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
WHEN ‘SXSD’.
* For BADis
wf_badi = wf_badi + 1 .
SELECT SINGLE text INTO wf_txt FROM sxs_attrt WHERE sprsl = sy-langu AND exit_name = wa_tadir-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED ON.
WHEN ‘ENHS’.
wf_badi = wf_badi + 1.
FORMAT COLOR COL_NORMAL INTENSIFIED ON.
READ TABLE it_badi_spot INTO wa_badi_spot WITH KEY
badi_name = wa_tadir-obj_name.
IF sy-subrc EQ 0.
otr_key-concept = wa_badi_spot-shorttext_obj.
CALL FUNCTION ‘SOTR_READ_TEXT_WITH_KEY’
EXPORTING
langu = sy-langu
context = otr_context
sotr_key = otr_key
IMPORTING
entry = otr_text
EXCEPTIONS
no_entry_found = 1
language_missing = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE
ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
MOVE otr_text-text TO wf_txt.
ENDIF.
ENDCASE.
WRITE:/1 sy-vline,
2 wa_tadir-obj_name HOTSPOT ON,
41 sy-vline , 42 wf_txt, 105 sy-vline.
AT END OF object.
WRITE : /(105) sy-uline.
ENDAT.
ENDLOOP.
WRITE:/(105) sy-uline.
SKIP.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ ‘No.of Exits:’ , wf_smod.
WRITE:/ ‘No.of BADis:’ , wf_badi.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(105) ‘No userexits or BADis exist’.
ENDIF.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE: /(105) ‘Transaction does not exist’.
ENDIF.
AT LINE-SELECTION.
DATA : wf_object TYPE tadir-object.
CLEAR wf_object.
GET CURSOR FIELD field1.
CHECK field1(8) EQ ‘WA_TADIR’.
READ TABLE jtab WITH KEY obj_name = sy-lisel+1(30).
MOVE jtab-object TO wf_object.
CASE wf_object.
WHEN ‘SMOD’.
SET PARAMETER ID ‘MON’
FIELD sy-lisel+1(10).
CALL TRANSACTION ‘SMOD’
AND SKIP FIRST SCREEN.
WHEN ‘SXSD’.
SET PARAMETER ID ‘EXN’
FIELD sy-lisel+1(20).
CALL TRANSACTION ‘SE18’ AND SKIP FIRST SCREEN.
WHEN ‘ENHS’.
SET PARAMETER ID ‘EXN’ FIELD sy-lisel+1(30).
CALL TRANSACTION ‘SE18’ AND SKIP FIRST SCREEN.
ENDCASE.