加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

一个功能强大的SAP增强出口查找工具(Add on 程序)(一)

(2013-04-04 13:47:19)
标签:

sap

abap

it

分类: SAP-ABAP

*&--------------------------------------------------------------------&* 
*& Report: Z_USEREXIT (V9) &* 
*& PJA Consultancy Services (www.pjas.com) &* 
*&--------------------------------------------------------------------&* 
*& This report attmpts to find Enhancements, Program-Exits, BADIs &* 
*& and Business Transaction Events in a particular program/tcode. &* 
*& Last updated: 09 May 2007 &* 
*&--------------------------------------------------------------------&* 
*& Selection Texts: 
*& P_ALV ALV format 
*& P_AUTH Include authority-check search 
*& P_BADI Display BADIs 
*& P_BTE Display business trans events 
*& P_DEVC Show development class exits 
*& P_EXIT Display user exits 
*& P_FUNC Show function modules 
*& P_LIMIT Limit no. of submits to search 
*& P_LST Standard list format 
*& P_PNAME Program name 
*& P_PROG Display program exits 
*& P_SUBM Show submits 
*& P_TCODE Transaction code 
*& P_TEXT Search for text 
*& P_WFLOW Display workflow links 
*&--------------------------------------------------------------------&* 
*& Text symbols: 
*& M01 Enter TCode or program 
*& M02 Enter at least one scope criteria 
*& S01 Selection data (TCode takes precedence over program name) 
*& S02 Scope criteria 
*& S03 Display criteria 
*&--------------------------------------------------------------------&*


report z_userexit 
no standard page heading 
line-size 201. 

tables: sxs_attr, 
tobjt, 
tstct, "TCode texts 
trdirt, "Program texts 
sxc_exit. "BADI exits 

type-pools: slis. "Globale Typen fьr generische Listbausteine 

data: tabix like sy-tabix, 
w_linnum type i, 
w_off type i, 
w_index like sy-tabix, 
w_include like trdir-name, 
w_prog like trdir-name, 
w_incl like trdir-name, 
w_area like rs38l-area, 
w_level, 
w_str(50) type c, 
w_cnt(2) type c, 
w_funcname like tfdir-funcname, 
w_fsel like sy-ucomm, " Determination of screen field 
w_gridtxt(70) type c. "ALV grid title 

constants: c_fmod(40) type c value 'Function modules searched: ', 
c_subm(40) type c value 'Submit programs searched: ', 
c_devc(60) type c value 'User-exits from development classes in function modules', 
c_col1(12) type c value 'Enhanmt Type', 
c_col2(40) type c value 'Enhancement', 
c_col3(30) type c value 'Program/Include', 
c_col4(20) type c value 'Enhancement Name', 
c_col5(40) type c value 'Enhancement Description', 
c_col6(8) type c value 'Project', 
c_col7(1) type c value 'S', 
c_col8(12) type c value 'ChangeName', 
c_col9(10) type c value 'ChangeDate', 
c_x type c value 'X'. 

* Work Areas: ABAP Workbench 
data: begin of wa_d010inc. 
data: master type d010inc-master. 
data: end of wa_d010inc. 

data: begin of wa_tfdir. 
data: funcname type tfdir-funcname, 
pname type tfdir-pname, 
include type tfdir-include. 
data: end of wa_tfdir. 

data: begin of wa_tadir. 
data: devclass type tadir-devclass. 
data: end of wa_tadir. 

data: begin of wa_tstc. 
data: pgmna type tstc-pgmna. 
data: end of wa_tstc. 

data: begin of wa_tstcp. 
data: param type tstcp-param. 
data: end of wa_tstcp. 

data: begin of wa_enlfdir. 
data: area type enlfdir-area. 
data: end of wa_enlfdir. 

* Work Areas: BADIs 
data: begin of wa_sxs_attr. 
data: exit_name type sxs_attr-exit_name. 
data: end of wa_sxs_attr. 

data: begin of wa_sxs_attrt. 
data: text type sxs_attrt-text. 
data: end of wa_sxs_attrt. 

* Work Areas: Enhancements 
data: begin of wa_modsap. 
data: member type modsap-member. 
data: end of wa_modsap. 

data: begin of wa_modsapa. 
data: name type modsapa-name. 
data: end of wa_modsapa. 

data: begin of wa_modsapt. 
data: modtext type modsapt-modtext. 
data: end of wa_modsapt. 

* Work Areas: Business Transaction Events 
data: begin of wa_tbe01t. 
data: text1 type tbe01t-text1. 
data: end of wa_tbe01t. 
data: begin of wa_tps01t. 
data: text1 type tps01t-text1. 
data: end of wa_tps01t. 

* user-exits 
types: begin of ty_mod, 
member like modact-member, 
name like modact-name, 
status like modattr-status, 
anam like modattr-anam, 
adat like modattr-adat, 
end of ty_mod. 
data: w_mod type ty_mod. 

types: begin of t_userexit, 
type(12) type c, 
pname like trdir-name, 
txt(300), 
level type c, 
modname(30) type c, 
modtext(60) type c, 
modattr type ty_mod, 
colour(4) type c, 
end of t_userexit. 
data: i_userexit type standard table of t_userexit with header line. 

* Function module developmnet classes 
types: begin of t_devclass, 
clas like trdir-clas, 
end of t_devclass. 
data: i_devclass type standard table of t_devclass with header line. 

* Submit programs 
types: begin of t_submit, 
pname like trdir-name, 
level, 
done, 
end of t_submit. 
data: i_submit type standard table of t_submit with header line. 

* Source code 
types: begin of t_sourcetab, "#EC * (SLIN lьgt!) 
line(200), "#EC * (SLIN lьgt!) 
end of t_sourcetab. "#EC * (SLIN lьgt!) 
data: sourcetab type standard table of t_sourcetab with header line. 
data c_overflow(30000) type c. 

* Description of an ABAP/4 source analysis token 
data: i_stoken type standard table of stokex with header line. 
data wa_stoken like i_stoken. 

* Description of an ABAP/4 source analysis statement 
data: i_sstmnt type standard table of sstmnt with header line."#EC NEEDED 

* keywords for searching ABAP code 
types: begin of t_keywords, 
word(30), 
end of t_keywords. 
data: keywords type standard table of t_keywords with header line. 

* function modules within program 
types: begin of t_fmodule, 
name like rs38l-name, 
pname like trdir-name, 
pname2 like trdir-name, 
level, 
bapi, 
done, 
end of t_fmodule. 
data: i_fmodule type standard table of t_fmodule with header line. 

* ALV definitions 
data i_fieldcat type slis_t_fieldcat_alv with header line. 
data i_layout type slis_layout_alv. 
data i_sort type slis_t_sortinfo_alv with header line. 

*&--------------------------------------------------------------------&* 
*& Selection Options &* 
*&--------------------------------------------------------------------&* 
selection-screen begin of block selscr1 with frame title text-s01. 
parameter: p_pname like trdir-name, 
p_tcode like syst-tcode, 
p_limit(4) type n default 500. 
selection-screen skip. 
selection-screen end of block selscr1. 

selection-screen begin of block selscr2 with frame title text-s02. 
parameter: p_badi as checkbox default c_x, 
p_bte as checkbox default c_x, 
p_exit as checkbox default c_x, 
p_prog as checkbox default c_x, 
p_wflow as checkbox, 
p_auth as checkbox. 
selection-screen skip. 
parameter: p_text(40) type c. 
selection-screen end of block selscr2. 

selection-screen begin of block selscr3 with frame title text-s03. 
parameter: p_alv radiobutton group rad1 default 'X', 
p_lst radiobutton group rad1. 
selection-screen skip. 
parameter: p_devc like rihea-dy_ofn default ' ' modif id a01, 
p_func like rihea-dy_ofn default ' ' modif id a01, 
p_subm like rihea-dy_ofn default ' ' modif id a01. 
selection-screen end of block selscr3. 

*&--------------------------------------------------------------------&* 
*& START-OF-SELECTION &* 
*&--------------------------------------------------------------------&* 
start-of-selection. 

if p_pname is initial and p_tcode is initial. 
message i000(g01) with text-m01. 
stop. 
endif. 

if p_badi is initial and 
p_exit is initial and 
p_bte is initial and 
p_wflow is initial and 
p_auth is initial and 
p_prog is initial. 
message i000(g01) with text-m02. 
stop. 
endif. 

* ensure P_LIMIT is not zero. 
if p_limit = 0. 
p_limit = 1. 
endif. 

perform data_select. 
perform get_submit_data. 
perform get_fm_data. 
perform get_additional_data. 
perform data_display. 

*&--------------------------------------------------------------------&* 
*& Form DATA_SELECT &* 
*&--------------------------------------------------------------------&* 
*& &* 
*&--------------------------------------------------------------------&* 
form data_select. 

* data selection message to sap gui 
call function 'SAPGUI_PROGRESS_INDICATOR' 
destination 'SAPGUI' 
keeping logical unit of work 
EXPORTING 
text = 'Get programs/includes' "#EC NOTEXT 
EXCEPTIONS 
system_failure 
communication_failure 
. "#EC * 

* get TCode name for ALV grid title 
clear w_gridtxt. 
if not p_tcode is initial. 
select single * from tstct where tcode = p_tcode 
and sprsl = sy-langu. 
concatenate 'TCode:' p_tcode tstct-ttext into w_gridtxt 
separated by space. 
endif. 
* get program name for ALV grid title 
if not p_pname is initial. 
select single * from trdirt where name = p_pname 
and sprsl = sy-langu. 
concatenate 'Program:' p_pname tstct-ttext into w_gridtxt 
separated by space. 
endif. 

* determine search words 
keywords-word = 'CALL'. 
append keywords. 
keywords-word = 'FORM'. 
append keywords. 
keywords-word = 'PERFORM'. 
append keywords. 
keywords-word = 'SUBMIT'. 
append keywords. 
keywords-word = 'INCLUDE'. 
append keywords. 
keywords-word = 'AUTHORITY-CHECK'. 
append keywords. 

if not p_tcode is initial. 
* get program name from TCode 
select single pgmna from tstc into wa_tstc-pgmna 
where tcode eq p_tcode. 
if not wa_tstc-pgmna is initial. 
p_pname = wa_tstc-pgmna. 
* TCode does not include program name, but does have reference TCode 
else. 
select single param from tstcp into wa_tstcp-param 
where tcode eq p_tcode. 
if sy-subrc = 0. 
check wa_tstcp-param(1) = '/'. 
check wa_tstcp-param+1(1) = '*'. 
if wa_tstcp-param ca ' '. 
endif. 
w_off = sy-fdpos + 1. 
subtract 2 from sy-fdpos. 
if sy-fdpos gt 0. 
p_tcode = wa_tstcp-param+2(sy-fdpos). 
endif. 
select single pgmna from tstc into wa_tstc-pgmna 
where tcode eq p_tcode. 
p_pname = wa_tstc-pgmna. 
if sy-subrc <> 0. 
message s110(/saptrx/asc) with 'No program found for: ' p_tcode."#EC NOTEXT 
stop. 
endif. 
else. 
message s110(/saptrx/asc) with 'No program found for: ' p_tcode."#EC NOTEXT 
stop. 
endif. 

endif. 
endif. 

* Call customer-function aus Program coding 
read report p_pname into sourcetab. 
if sy-subrc > 0. 
message e017(enhancement) with p_pname raising no_program."#EC * 
endif. 

scan abap-source sourcetab tokens into i_stoken 
statements into i_sstmnt 
keywords from keywords 
overflow into c_overflow 
with includes. "#EC 
if sy-subrc > 0. "keine/syntakt. falsche Ablauflog./Fehler im Skanner 
message e130(enhancement) raising syntax_error. "#EC 
endif. 

* check I_STOKEN for entries 
clear w_linnum. 
describe table i_stoken lines w_linnum. 
if w_linnum gt 0. 
w_level = '0'. 
w_prog = ''. 
w_incl = ''. 
perform data_search tables i_stoken using w_level w_prog w_incl. 
endif. 

endform. "DATA_SELECT 

*&--------------------------------------------------------------------&* 
*& Form GET_FM_DATA ௥ &* 
*&--------------------------------------------------------------------&* 
*& &* 
*&--------------------------------------------------------------------&* 
form get_fm_data. 

* data selection message to sap gui 
call function 'SAPGUI_PROGRESS_INDICATOR' 
destination 'SAPGUI' 
keeping logical unit of work 
EXPORTING 
text = 'Get function module data' "#EC NOTEXT 
EXCEPTIONS 
system_failure 
communication_failure 
. "#EC * 

* Function module data 
sort i_fmodule by name. 
delete adjacent duplicates from i_fmodule comparing name. 

loop at i_fmodule where done ne c_x. 

clear: i_stoken, i_sstmnt, sourcetab, wa_tfdir, w_include . 
refresh: i_stoken, i_sstmnt, sourcetab. 

clear wa_tfdir. 
select single funcname pname include from tfdir into wa_tfdir 
where funcname = i_fmodule-name. 
check sy-subrc = 0. 

call function 'FUNCTION_INCLUDE_SPLIT' 
EXPORTING 
program = wa_tfdir-pname 
IMPORTING 
group = w_area. 

concatenate 'L' w_area 'U' wa_tfdir-include into w_include. 
i_fmodule-pname = w_include. 
i_fmodule-pname2 = wa_tfdir-pname. 
modify i_fmodule. 

read report i_fmodule-pname into sourcetab. 
if sy-subrc = 0. 

scan abap-source sourcetab tokens into i_stoken 
statements into i_sstmnt 
keywords from keywords 
with includes. 
if sy-subrc > 0. 
message e130(enhancement) raising syntax_error. 
endif. 

* check i_stoken for entries 
clear w_linnum. 
describe table i_stoken lines w_linnum. 
if w_linnum gt 0. 
w_level = '1'. 
w_prog = i_fmodule-pname2. 
w_incl = i_fmodule-pname. 
perform data_search tables i_stoken using w_level w_prog w_incl. 
endif. 
endif. 

endloop. 

* store development classes 
if p_devc = c_x. 
loop at i_fmodule. 
clear: wa_tadir, wa_enlfdir. 

select single area from enlfdir into wa_enlfdir-area 
where funcname = i_fmodule-name. 
check not wa_enlfdir-area is initial. 

select single devclass into wa_tadir-devclass 
from tadir where pgmid = 'R3TR' 
and object = 'FUGR' 
and obj_name = wa_enlfdir-area. 
check not wa_tadir-devclass is initial. 
move wa_tadir-devclass to i_devclass-clas. 
append i_devclass. 
i_fmodule-done = c_x. 
modify i_fmodule. 
endloop. 

sort i_devclass. 
delete adjacent duplicates from i_devclass. 
endif. 

endform. "GET_FM_DATA 

*&--------------------------------------------------------------------&* 
*& Form GET_SUBMIT_DATA &* 
*&--------------------------------------------------------------------&* 
*& &* 
*&--------------------------------------------------------------------&* 
form get_submit_data. 

* data selection message to sap gui 
call function 'SAPGUI_PROGRESS_INDICATOR' 
destination 'SAPGUI' 
keeping logical unit of work 
EXPORTING 
text = 'Get submit data' "#EC NOTEXT 
EXCEPTIONS 
system_failure 
communication_failure 
. "#EC * 

sort i_submit. 
delete adjacent duplicates from i_submit comparing pname. 
w_level = '0'. 

loop at i_submit where done ne c_x. 

clear: i_stoken, i_sstmnt, sourcetab. 
refresh: i_stoken, i_sstmnt, sourcetab. 

read report i_submit-pname into sourcetab. 
if sy-subrc = 0. 

scan abap-source sourcetab tokens into i_stoken 
statements into i_sstmnt 
keywords from keywords 
with includes. 
if sy-subrc > 0. 
* message e130(enhancement) raising syntax_error. 
continue. 
endif. 

* check i_stoken for entries 
clear w_linnum. 
describe table i_stoken lines w_linnum. 
if w_linnum gt 0. 
w_prog = i_submit-pname. 
w_incl = ''. 
perform data_search tables i_stoken using w_level w_prog w_incl. 
endif. 
endif. 

* restrict number of submit program selected for processing 
describe table i_submit lines w_linnum. 
if w_linnum ge p_limit. 
w_level = '1'. 
endif. 
i_submit-done = c_x. 
modify i_submit. 
endloop. 

endform. "GET_SUBMIT_DATA 



0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有