Tuesday, July 24, 2007

To find User Exit For A Transaction

To find User Exit For A Transaction

If you know the Exit name, go to transaction CMOD. Choose menu Utillities->SAP Enhancements. Enter the exit name and press enter.You will now come to a screen that shows the function module exits for the exit.

( or follow this)

Use the below code to find User exit for a transaction.Give the TCODE as input.
*&---------------------------------------------------------------------*
*& Report zuserexit
*&---------------------------------------------------------------------*
*& This program helps find Exits for any given transaction
*& This code is originally adopted from http://www.sap-img.com
*&---------------------------------------------------------------------*
report zuserexit no standard page heading.
*----------------------------------------------------------------------*
*TABLES
*----------------------------------------------------------------------*

tables :
tstc,
tadir,
modsapt,
modact,
trdir,
tfdir,
enlfdir,
tstct.

*----------------------------------------------------------------------*
*INTERNAL TABLES AND STRUCTURES
*----------------------------------------------------------------------*
*** Internal table to hold Repository Objects
data : jtab like tadir occurs 0 with header line.
*----------------------------------------------------------------------*
*Global variables
*----------------------------------------------------------------------*
data : field1(30).
data : v_devclass like tadir-devclass.
*----------------------------------------------------------------------*
*SELECTION-SCREEN
*----------------------------------------------------------------------*
parameters : p_tcode like tstc-tcode obligatory.

*----------------------------------------------------------------------*
*START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
* SELECT construct to get data for a given tcode
select single * from tstc where tcode eq p_tcode.

if sy-subrc eq 0.

* SELECT construct to get program names
select single * from tadir where pgmid = 'R3TR'
and object = 'PROG'
and obj_name = tstc-pgmna.

* Moving the dev. class to v_devclass if program is of type 1
move : tadir-devclass to v_devclass.
if sy-subrc ne 0.
select single * from trdir where name = tstc-pgmna.

* If Program type = Function Group

if trdir-subc eq 'F'.
select single * from tfdir where pname = tstc-pgmna.

* SELECT construct to get Attributes for Function Modules
select single * from enlfdir where funcname = tfdir-funcname.

* SELECT construct to get FM names
select single * from tadir where pgmid = 'R3TR'
and object = 'FUGR'
and obj_name eq enlfdir-area.

* Moving the dev. class to v_devclass if program is of type F
move : tadir-devclass to v_devclass.
endif.
endif.

* SELECT construct to get SAP enhancements for the dev. class
select * from tadir into table jtab
where pgmid = 'R3TR'
and object = 'SMOD'
and devclass = v_devclass.

* SELECT construct to get t code texts
select single * from tstct
where sprsl eq sy-langu
and tcode eq p_tcode.

* REPORT OUTPUT
format color col_positive intensified off.

* Displaying t-code name & text
write:/(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
skip.

* List headings
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.

* SELECT construct to get SAP Enhancements - Short Texts
loop at jtab.

select single * from modsapt where sprsl = sy-langu
and name = jtab-obj_name.

format color col_normal intensified off.

* Exit names & texts
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.

* No of Exits
write:/ 'No of Exits:' ,
sy-tfill.
else.
format color col_negative intensified on.

* If no exits found
write:/(95) 'No User Exit exists'.
endif.
else.

format color col_negative intensified on.

* If tcode doesn't exist
write:/(95) 'Transaction Code Does Not Exist'.
endif.

* Call txn SMOD with selected Exit
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.

No comments: