_______________________________________________________________________________________________________________________

Home :: Sample Code :: Tutorials :: Interview FAQs :: Material :: SAP Books :: About :: Contact :: Links :: Disclaimer
_______________________________________________________________________________________________________________________

Sep 6, 2007

Program to find User Exits for a given tcode

*&---------------------------------------------------------------------*
*& Report ZKAR_FINDEXITS
*&---------------------------------------------------------------------*
*& This program helps find Exits for any given transaction
*& This code is originally adopted from http://www.sap-img.com
*&---------------------------------------------------------------------*
REPORT ZKAR_FINDEXITS no standard page heading.
*----------------------------------------------------------------------*
*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
*----------------------------------------------------------------------*
*INTERNAL TABLES AND STRUCTURES
*----------------------------------------------------------------------*

*** Internal table to hold Repository Objects
data :
it_tadir like tadir occurs 0 with header line.
*----------------------------------------------------------------------*
*Global variables
*----------------------------------------------------------------------*

data :
field1(30),
v_devclass like tadir-devclass. " variable to hold dev. class
*----------------------------------------------------------------------*
*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 = 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 <> 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 = 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 IT_tadir
where pgmid = 'R3TR'
and object = 'SMOD'
and devclass = v_devclass.
* SELECT construct to get t code texts
select single * from tstct
where sprsl = sy-langu
and tcode = p_tcode.
* REPORT OUTPUT
format color 2.
* Displaying t-code name & text
write:/(19) 'T Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
skip.
* List headings
if not IT_tadir[] 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 IT_tadir.
* SELECT construct to get SAP Enhancements - Short Texts
select single * from modsapt
where sprsl = sy-langu

and name = IT_tadir-obj_name.
format color col_normal intensified off.
* Exit names & texts
write:/1 sy-vline,
2 IT_tadir-obj_name hotspot on,
21 sy-vline ,
22 modsapt-modtext,
95 sy-vline.
endloop.
write:/(95) sy-uline.
describe table IT_tadir.
skip.
format color 1 intensified on.
* No of Exits
write:/ 'No of Exits:' , sy-tfill.
else.
format color 3 intensified on.
* If no exits found
write:/(95) 'No User Exit exists'.
endif.
else.
format color 3 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) = 'IT_tadir'.
set parameter id 'MON' field sy-lisel+1(10).
call transaction 'SMOD' and skip first screen.

No comments:

Subscribe to posts via email

Enter your email address:

Delivered by FeedBurner

Blog Owner

Karthik P
Certified SAP Netweaver Consultant

View Karthik Potharaju's profile on LinkedIn