二维码

[其他] 一个功能非常全面的增强出口查找工具

Twilight发表于 2014-03-30 21:18www.sapabap 最后回复于 2021-06-10 14:52 [复制链接] 7906 9

查找增强程序的选择屏幕
查找增强程序.jpg

程序代码:
  1. *&--------------------------------------------------------------------&*
  2. *& Report: zdamon_004 (V9) &*
  3. *& PJA Consultancy Services (www.pjas.com) &*
  4. *&--------------------------------------------------------------------&*
  5. *& This report attmpts to find Enhancements, Program-Exits, BADIs &*
  6. *& and Business Transaction Events in a particular program/tcode. &*
  7. *& Last updated: 09 May 2007 &*
  8. *&--------------------------------------------------------------------&*
  9. *& Selection Texts:
  10. *& P_ALV ALV format
  11. *& P_AUTH Include authority-check search
  12. *& P_BADI Display BADIs
  13. *& P_BTE Display business trans events
  14. *& P_DEVC Show development class exits
  15. *& P_EXIT Display user exits
  16. *& P_FUNC Show function modules
  17. *& P_LIMIT Limit no. of submits to search
  18. *& P_LST Standard list format
  19. *& P_PNAME Program name
  20. *& P_PROG Display program exits
  21. *& P_SUBM Show submits
  22. *& P_TCODE Transaction code
  23. *& P_TEXT Search for text
  24. *& P_WFLOW Display workflow links
  25. *&--------------------------------------------------------------------&*
  26. *& Text symbols:
  27. *& M01 Enter TCode or program
  28. *& M02 Enter at least one scope criteria
  29. *& S01 Selection data (TCode takes precedence over program name)
  30. *& S02 Scope criteria
  31. *& S03 Display criteria
  32. *&--------------------------------------------------------------------&*
  33. report zdamon_004
  34. no standard page heading
  35. line-size 201.

  36. tables: sxs_attr,
  37.   tobjt,
  38.   tstct, "TCode texts
  39.   trdirt, "Program texts
  40.   sxc_exit. "BADI exits

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

  42. data: tabix like sy-tabix,
  43.       w_linnum type i,
  44.       w_off type i,
  45.       w_index like sy-tabix,
  46.       w_include like trdir-name,
  47.       w_prog like trdir-name,
  48.       w_incl like trdir-name,
  49.       w_area like rs38l-area,
  50.       w_level,
  51.       w_str(50) type c,
  52.       w_cnt(2) type c,
  53.       w_funcname like tfdir-funcname,
  54.       w_fsel like sy-ucomm, " Determination of screen field
  55.       w_gridtxt(70) type c. "ALV grid title

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

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

  73. data: begin of wa_tfdir.
  74. data: funcname type tfdir-funcname,
  75.       pname type tfdir-pname,
  76.       include type tfdir-include.
  77. data: end of wa_tfdir.

  78. data: begin of wa_tadir.
  79. data: devclass type tadir-devclass.
  80. data: end of wa_tadir.

  81. data: begin of wa_tstc.
  82. data: pgmna type tstc-pgmna.
  83. data: end of wa_tstc.

  84. data: begin of wa_tstcp.
  85. data: param type tstcp-param.
  86. data: end of wa_tstcp.

  87. data: begin of wa_enlfdir.
  88. data: area type enlfdir-area.
  89. data: end of wa_enlfdir.

  90. * Work Areas: BADIs
  91. data: begin of wa_sxs_attr.
  92. data: exit_name type sxs_attr-exit_name.
  93. data: end of wa_sxs_attr.

  94. data: begin of wa_sxs_attrt.
  95. data: text type sxs_attrt-text.
  96. data: end of wa_sxs_attrt.

  97. * Work Areas: Enhancements
  98. data: begin of wa_modsap.
  99. data: member type modsap-member.
  100. data: end of wa_modsap.

  101. data: begin of wa_modsapa.
  102. data: name type modsapa-name.
  103. data: end of wa_modsapa.

  104. data: begin of wa_modsapt.
  105. data: modtext type modsapt-modtext.
  106. data: end of wa_modsapt.

  107. * Work Areas: Business Transaction Events
  108. data: begin of wa_tbe01t.
  109. data: text1 type tbe01t-text1.
  110. data: end of wa_tbe01t.

  111. data: begin of wa_tps01t.
  112. data: text1 type tps01t-text1.
  113. data: end of wa_tps01t.

  114. * user-exits
  115. types: begin of ty_mod,
  116. member like modact-member,
  117. name like modact-name,
  118. status like modattr-status,
  119. anam like modattr-anam,
  120. adat like modattr-adat,
  121. end of ty_mod.
  122. data: w_mod type ty_mod.

  123. types: begin of t_userexit,
  124. type(12) type c,
  125. pname like trdir-name,
  126. txt(300),
  127. level type c,
  128. modname(30) type c,
  129. modtext(60) type c,
  130. modattr type ty_mod,
  131. colour(4) type c,
  132. end of t_userexit.
  133. data: i_userexit type standard table of t_userexit with header line.

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

  139. * Submit programs
  140. types: begin of t_submit,
  141. pname like trdir-name,
  142. level,
  143. done,
  144. end of t_submit.
  145. data: i_submit type standard table of t_submit with header line.

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

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

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

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

  162. * function modules within program
  163. types: begin of t_fmodule,
  164. name like rs38l-name,
  165. pname like trdir-name,
  166. pname2 like trdir-name,
  167. level,
  168. bapi,
  169. done,
  170. end of t_fmodule.
  171. data: i_fmodule type standard table of t_fmodule with header line.

  172. * ALV definitions
  173. data i_fieldcat type slis_t_fieldcat_alv with header line.
  174. data i_layout type slis_layout_alv.
  175. data i_sort type slis_t_sortinfo_alv with header line.

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

  185. selection-screen begin of block selscr2 with frame title text-s02.
  186. parameter: p_badi as checkbox default c_x,
  187. p_bte as checkbox default c_x,
  188. p_exit as checkbox default c_x,
  189. p_prog as checkbox default c_x,
  190. p_wflow as checkbox,
  191. p_auth as checkbox.
  192. selection-screen skip.
  193. parameter: p_text(40) type c.
  194. selection-screen end of block selscr2.

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

  203. *&--------------------------------------------------------------------&*
  204. *& START-OF-SELECTION &*
  205. *&--------------------------------------------------------------------&*
  206. start-of-selection.

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

  211. if p_badi is initial and
  212. p_exit is initial and
  213. p_bte is initial and
  214. p_wflow is initial and
  215. p_auth is initial and
  216. p_prog is initial.
  217. message i000(g01) with text-m02.
  218. stop.
  219. endif.

  220. * ensure P_LIMIT is not zero.
  221. if p_limit = 0.
  222. p_limit = 1.
  223. endif.

  224. perform data_select.
  225. perform get_submit_data.
  226. perform get_fm_data.
  227. perform get_additional_data.
  228. perform data_display.

  229. *&--------------------------------------------------------------------&*
  230. *& Form DATA_SELECT &*
  231. *&--------------------------------------------------------------------&*
  232. *& &*
  233. *&--------------------------------------------------------------------&*
  234. form data_select.

  235. * data selection message to sap gui
  236. call function 'SAPGUI_PROGRESS_INDICATOR'
  237. destination 'SAPGUI'
  238. keeping logical unit of work
  239. EXPORTING
  240.   text = 'Get programs/includes' "#EC NOTEXT
  241. EXCEPTIONS
  242.   system_failure
  243.   communication_failure
  244.   . "#EC *

  245. * get TCode name for ALV grid title
  246. clear w_gridtxt.
  247. if not p_tcode is initial.
  248. select single * from tstct where tcode = p_tcode
  249. and sprsl = sy-langu.
  250. concatenate 'TCode:' p_tcode tstct-ttext into w_gridtxt
  251. separated by space.
  252. endif.
  253. * get program name for ALV grid title
  254. if not p_pname is initial.
  255. select single * from trdirt where name = p_pname
  256. and sprsl = sy-langu.
  257. concatenate 'Program:' p_pname tstct-ttext into w_gridtxt
  258. separated by space.
  259. endif.

  260. * determine search words
  261. keywords-word = 'CALL'.
  262. append keywords.
  263. keywords-word = 'FORM'.
  264. append keywords.
  265. keywords-word = 'PERFORM'.
  266. append keywords.
  267. keywords-word = 'SUBMIT'.
  268. append keywords.
  269. keywords-word = 'INCLUDE'.
  270. append keywords.
  271. keywords-word = 'AUTHORITY-CHECK'.
  272. append keywords.

  273. if not p_tcode is initial.
  274. * get program name from TCode
  275. select single pgmna from tstc into wa_tstc-pgmna
  276. where tcode eq p_tcode.
  277. if not wa_tstc-pgmna is initial.
  278. p_pname = wa_tstc-pgmna.
  279. * TCode does not include program name, but does have reference TCode
  280. else.
  281. select single param from tstcp into wa_tstcp-param
  282. where tcode eq p_tcode.
  283. if sy-subrc = 0.
  284. check wa_tstcp-param(1) = '/'.
  285. check wa_tstcp-param+1(1) = '*'.
  286. if wa_tstcp-param ca ' '.
  287. endif.
  288. w_off = sy-fdpos + 1.
  289. subtract 2 from sy-fdpos.
  290. if sy-fdpos gt 0.
  291. p_tcode = wa_tstcp-param+2(sy-fdpos).
  292. endif.
  293. select single pgmna from tstc into wa_tstc-pgmna
  294. where tcode eq p_tcode.
  295. p_pname = wa_tstc-pgmna.
  296. if sy-subrc <> 0.
  297. message s110(/saptrx/asc) with 'No program found for: ' p_tcode."#EC NOTEXT
  298. stop.
  299. endif.
  300. else.
  301. message s110(/saptrx/asc) with 'No program found for: ' p_tcode."#EC NOTEXT
  302. stop.
  303. endif.

  304. endif.
  305. endif.

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

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

  315. * check I_STOKEN for entries
  316. clear w_linnum.
  317. describe table i_stoken lines w_linnum.
  318. if w_linnum gt 0.
  319. w_level = '0'.
  320. w_prog = ''.
  321. w_incl = ''.
  322. perform data_search tables i_stoken using w_level w_prog w_incl.
  323. endif.

  324. endform. "DATA_SELECT

  325. *&--------------------------------------------------------------------&*
  326. *& Form GET_FM_DATA ? &*
  327. *&--------------------------------------------------------------------&*
  328. *& &*
  329. *&--------------------------------------------------------------------&*
  330. form get_fm_data.

  331. * data selection message to sap gui
  332. call function 'SAPGUI_PROGRESS_INDICATOR'
  333. destination 'SAPGUI'
  334. keeping logical unit of work
  335. EXPORTING
  336.   text = 'Get function module data' "#EC NOTEXT
  337. EXCEPTIONS
  338.   system_failure
  339.   communication_failure
  340.   . "#EC *

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

  344. loop at i_fmodule where done ne c_x.

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

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

  351. call function 'FUNCTION_INCLUDE_SPLIT'
  352. EXPORTING
  353.   program = wa_tfdir-pname
  354. IMPORTING
  355.   group = w_area.

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

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

  362. scan abap-source sourcetab tokens into i_stoken
  363. statements into i_sstmnt
  364. keywords from keywords
  365. with includes WITH ANALYSIS.
  366. if sy-subrc > 0.
  367. message e130(enhancement) raising syntax_error.
  368. endif.

  369. * check i_stoken for entries
  370. clear w_linnum.
  371. describe table i_stoken lines w_linnum.
  372. if w_linnum gt 0.
  373. w_level = '1'.
  374. w_prog = i_fmodule-pname2.
  375. w_incl = i_fmodule-pname.
  376. perform data_search tables i_stoken using w_level w_prog w_incl.
  377. endif.
  378. endif.

  379. endloop.

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

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

  387. select single devclass into wa_tadir-devclass
  388. from tadir where pgmid = 'R3TR'
  389. and object = 'FUGR'
  390. and obj_name = wa_enlfdir-area.
  391. check not wa_tadir-devclass is initial.
  392. move wa_tadir-devclass to i_devclass-clas.
  393. append i_devclass.
  394. i_fmodule-done = c_x.
  395. modify i_fmodule.
  396. endloop.

  397. sort i_devclass.
  398. delete adjacent duplicates from i_devclass.
  399. endif.

  400. endform. "GET_FM_DATA
  401. *&--------------------------------------------------------------------&*
  402. *& Form GET_SUBMIT_DATA &*
  403. *&--------------------------------------------------------------------&*
  404. *& &*
  405. *&--------------------------------------------------------------------&*
  406. form get_submit_data.

  407. * data selection message to sap gui
  408. call function 'SAPGUI_PROGRESS_INDICATOR'
  409. destination 'SAPGUI'
  410. keeping logical unit of work
  411. EXPORTING
  412.   text = 'Get submit data' "#EC NOTEXT
  413. EXCEPTIONS
  414.   system_failure
  415.   communication_failure
  416.   . "#EC *

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

  420. loop at i_submit where done ne c_x.

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

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

  425. scan abap-source sourcetab tokens into i_stoken
  426. statements into i_sstmnt
  427. keywords from keywords
  428. with includes WITH ANALYSIS.
  429. if sy-subrc > 0.
  430. * message e130(enhancement) raising syntax_error.
  431. continue.
  432. endif.

  433. * check i_stoken for entries
  434. clear w_linnum.
  435. describe table i_stoken lines w_linnum.
  436. if w_linnum gt 0.
  437. w_prog = i_submit-pname.
  438. w_incl = ''.
  439. perform data_search tables i_stoken using w_level w_prog w_incl.
  440. endif.
  441. endif.

  442. * restrict number of submit program selected for processing
  443. describe table i_submit lines w_linnum.
  444. if w_linnum ge p_limit.
  445. w_level = '1'.
  446. endif.
  447. i_submit-done = c_x.
  448. modify i_submit.
  449. endloop.

  450. endform. "GET_SUBMIT_DATA

  451. *&--------------------------------------------------------------------&*
  452. *& Form DATA_SEARCH &*
  453. *&--------------------------------------------------------------------&*
  454. *& &*
  455. *&--------------------------------------------------------------------&*
  456. form data_search tables p_stoken structure stoken
  457. using p_level l_prog l_incl.

  458. loop at p_stoken.

  459. clear i_userexit.

  460. * Workflow
  461. if p_wflow = c_x.
  462. if p_level eq '1'. " do not perform for function modules (2nd pass)
  463. if p_stoken-str+1(16) cs 'SWE_EVENT_CREATE'.
  464. replace all occurrences of '''' in p_stoken-str with ''.
  465. i_userexit-type = 'WorkFlow'.
  466. i_userexit-txt = p_stoken-str.
  467. concatenate l_prog '/' l_incl into i_userexit-pname.
  468. append i_userexit.
  469. endif.
  470. endif.
  471. endif.

  472. tabix = sy-tabix + 1.
  473. i_userexit-level = p_level.
  474. if i_userexit-level = '0'.
  475. if l_incl is initial.
  476. i_userexit-pname = p_pname.
  477. else.
  478. concatenate p_pname '-' l_incl into i_userexit-pname.
  479. endif.
  480. else.
  481. if l_incl is initial.
  482. i_userexit-pname = l_prog.
  483. else.
  484. concatenate l_prog '-' l_incl into i_userexit-pname.
  485. endif.
  486. endif.

  487. * AUTHORITY-CHECKS
  488. if p_auth = c_x.
  489. if p_stoken-str eq 'AUTHORITY-CHECK'.
  490. check p_level eq '0'. " do not perform for function modules (2nd pass)
  491. w_index = sy-tabix + 2.
  492. read table p_stoken index w_index into wa_stoken.
  493. check not wa_stoken-str cs 'STRUCTURE'.
  494. check not wa_stoken-str cs 'SYMBOL'.
  495. read table i_submit with key pname = wa_stoken-str.
  496. if sy-subrc <> 0.
  497. i_userexit-pname = i_submit-pname.
  498. i_userexit-type = 'AuthCheck'.
  499. i_userexit-txt = wa_stoken-str.
  500. replace all occurrences of '''' in i_userexit-txt with space.
  501. clear tobjt.
  502. select single * from tobjt where object = i_userexit-txt
  503. and langu = sy-langu.
  504. i_userexit-modname = 'AUTHORITY-CHECK'.
  505. i_userexit-modtext = tobjt-ttext.
  506. append i_userexit.
  507. endif.
  508. endif.
  509. endif.

  510. * Text searches
  511. if not p_text is initial.
  512. if p_stoken-str cs p_text.
  513. i_userexit-pname = i_submit-pname.
  514. i_userexit-type = 'TextSearch'.
  515. i_userexit-txt = wa_stoken-str.
  516. i_userexit-modname = 'Text Search'.
  517. i_userexit-modtext = p_stoken-str.
  518. append i_userexit.
  519. endif.
  520. endif.

  521. * Include (SE38)
  522. if p_stoken-str eq 'INCLUDE'.
  523. check p_level eq '0'. " do not perform for function modules (2nd pass)
  524. w_index = sy-tabix + 1.
  525. read table p_stoken index w_index into wa_stoken.
  526. check not wa_stoken-str cs 'STRUCTURE'.
  527. check not wa_stoken-str cs 'SYMBOL'.
  528. read table i_submit with key pname = wa_stoken-str.
  529. if sy-subrc <> 0.
  530. i_submit-pname = wa_stoken-str.
  531. i_submit-level = p_level.
  532. append i_submit.
  533. endif.
  534. endif.

  535. * Enhancements (SMOD)
  536. if p_exit = c_x.
  537. if p_stoken-str eq 'CUSTOMER-FUNCTION'.
  538. clear w_funcname.
  539. read table p_stoken index tabix.
  540. translate p_stoken-str using ''' '.
  541. condense p_stoken-str.
  542. if l_prog is initial.
  543. concatenate 'EXIT' p_pname p_stoken-str into w_funcname
  544. separated by '_'.
  545. else.
  546. concatenate 'EXIT' l_prog p_stoken-str into w_funcname
  547. separated by '_'.
  548. endif.
  549. select single member from modsap into wa_modsap-member
  550. where member = w_funcname.
  551. if sy-subrc = 0. " check for valid enhancement
  552. i_userexit-type = 'Enhancement'.
  553. i_userexit-txt = w_funcname.
  554. append i_userexit.
  555. else.
  556. clear wa_d010inc.
  557. select single master into wa_d010inc-master
  558. from d010inc
  559. where include = l_prog.
  560. concatenate 'EXIT' wa_d010inc-master p_stoken-str into w_funcname
  561. separated by '_'.
  562. i_userexit-type = 'Enhancement'.
  563. i_userexit-txt = w_funcname.
  564. endif.
  565. endif.
  566. endif.

  567. * BADIs (SE18)
  568. if p_badi = c_x.
  569. if p_stoken-str cs 'cl_exithandler='.
  570. w_index = sy-tabix + 4.
  571. read table p_stoken index w_index into wa_stoken.
  572. i_userexit-txt = wa_stoken-str.
  573. replace all occurrences of '''' in i_userexit-txt with space.
  574. i_userexit-type = 'BADI'.
  575. clear sxs_attr. " ensure a real BADI
  576. select single * from sxs_attr where exit_name = i_userexit-txt.
  577. if sy-subrc = 0.
  578. append i_userexit.
  579. endif.
  580. endif.
  581. endif.

  582. * Business transaction events (FIBF)
  583. if p_bte = c_x.
  584. if p_stoken-str cs 'OPEN_FI_PERFORM'.
  585. i_userexit-type = 'BusTrEvent'.
  586. i_userexit-txt = p_stoken-str.
  587. replace all occurrences of '''' in i_userexit-txt with space.
  588. i_userexit-modname = i_userexit-txt+16(8).
  589. case i_userexit-txt+25(1).
  590. when 'E'.
  591. clear wa_tbe01t.
  592. select single text1 into wa_tbe01t-text1 from tbe01t
  593. where event = i_userexit-txt+16(8)
  594. and spras = sy-langu.
  595. if wa_tbe01t-text1 is initial.
  596. i_userexit-modtext = '<Not active>'. "#EC NOTEXT
  597. else.
  598. i_userexit-modtext = wa_tbe01t-text1.
  599. endif.
  600. i_userexit-modname+8 = '/P&S'. "#EC NOTEXT
  601. when 'P'.
  602. clear wa_tps01t.
  603. select single text1 into wa_tps01t-text1 from tps01t
  604. where procs = i_userexit-txt+16(8)
  605. and spras = sy-langu.
  606. i_userexit-modtext = wa_tps01t-text1.
  607. i_userexit-modname+8 = '/Process'.
  608. endcase.

  609. append i_userexit.
  610. endif.
  611. endif.

  612. * Program exits (SE38)
  613. if p_prog = c_x.
  614. if p_stoken-str cs 'USEREXIT_'.
  615. check not p_stoken-str cs '-'. " ensure not USEREXIT_XX-XXX
  616. check not p_stoken-str cs '('. " ensure not SUBMIT_XX(X)
  617. i_userexit-type = 'Program Exit'.
  618. i_userexit-txt = p_stoken-str.
  619. replace all occurrences of '''' in i_userexit-txt with space.
  620. append i_userexit.
  621. endif.
  622. endif.

  623. * Submit programs (SE38)
  624. if p_stoken-str cs 'SUBMIT'.
  625. check p_level eq '0'. " do not perform for function modules (2nd pass)
  626. check not p_stoken-str cs '_'. " ensure not SUBMIT_XXX
  627. w_index = sy-tabix + 1.
  628. read table p_stoken index w_index into wa_stoken.
  629. check not wa_stoken-str cs '_'. " ensure not SUBMIT_XXX
  630. replace all occurrences of '''' in wa_stoken-str with space.
  631. read table i_submit with key pname = wa_stoken-str.
  632. if sy-subrc <> 0.
  633. i_submit-pname = wa_stoken-str.
  634. i_submit-level = p_level.
  635. append i_submit.
  636. endif.
  637. endif.

  638. * Perform routines (which reference external programs)
  639. if p_stoken-str cs 'PERFORM'.
  640. check p_level eq '0'. " do not perform for function modules (2nd pass)
  641. w_index = sy-tabix + 1.
  642. read table p_stoken index w_index into wa_stoken.
  643. if not wa_stoken-ovfl is initial.
  644. w_off = wa_stoken-off1 + 10.
  645. w_str = c_overflow+w_off(30).
  646. find ')' in w_str match offset w_off.
  647. if sy-subrc = 0.
  648. w_off = w_off + 1.
  649. wa_stoken-str = w_str(w_off).
  650. endif.
  651. endif.

  652. check wa_stoken-str cs '('.
  653. w_off = 0.
  654. while sy-subrc = 0.
  655. if wa_stoken-str+w_off(1) eq '('.
  656. replace section offset w_off length 1 of wa_stoken-str with ''.
  657. replace all occurrences of ')' in wa_stoken-str with space.
  658. read table i_submit with key pname = wa_stoken-str.
  659. if sy-subrc <> 0.
  660. i_submit-pname = wa_stoken-str.
  661. append i_submit.
  662. endif.
  663. exit.
  664. else.
  665. replace section offset w_off length 1 of wa_stoken-str with ''.
  666. shift wa_stoken-str left deleting leading space.
  667. endif.
  668. endwhile.
  669. endif.

  670. * Function modules (SE37)
  671. if p_stoken-str cs 'FUNCTION'.

  672. clear i_fmodule.
  673. if p_level eq '0'. " do not perform for function modules (2nd pass)
  674. w_index = sy-tabix + 1.
  675. read table p_stoken index w_index into wa_stoken.

  676. if wa_stoken-str cs 'BAPI'.
  677. i_fmodule-bapi = c_x.
  678. endif.

  679. replace first occurrence of '''' in wa_stoken-str with space.
  680. replace first occurrence of '''' in wa_stoken-str with space.
  681. if sy-subrc = 4. " didn't find 2nd quote (ie name truncated)
  682. clear wa_tfdir.
  683. concatenate wa_stoken-str '%' into wa_stoken-str.
  684. select single funcname into wa_tfdir-funcname from tfdir
  685. where funcname like wa_stoken-str.
  686. if sy-subrc = 0.
  687. i_fmodule-name = wa_tfdir-funcname.
  688. else.
  689. continue.
  690. endif.
  691. else.
  692. i_fmodule-name = wa_stoken-str.
  693. endif.
  694. i_fmodule-level = p_level.
  695. append i_fmodule.
  696. endif.
  697. endif.

  698. endloop.

  699. endform. "DATA_SEARCH
  700. *&--------------------------------------------------------------------&*
  701. *& Form GET_ADDITIONAL_DATA &*
  702. *&--------------------------------------------------------------------&*
  703. *& &*
  704. *&--------------------------------------------------------------------&*
  705. form get_additional_data.

  706. * data selection message to sap gui
  707. call function 'SAPGUI_PROGRESS_INDICATOR'
  708. destination 'SAPGUI'
  709. keeping logical unit of work
  710. EXPORTING
  711.   text = 'Get additional data' "#EC NOTEXT
  712. EXCEPTIONS
  713.   system_failure
  714.   communication_failure
  715.   . "#EC *

  716. loop at i_userexit.

  717. * Workflow
  718. if i_userexit-type eq 'WorkFlow'.
  719. continue.
  720. endif.



  721. * Enhancement data
  722. if i_userexit-type cs 'Enh'.
  723. clear: wa_modsapa.
  724. select single name into wa_modsapa-name from modsap
  725. where member = i_userexit-txt.
  726. check sy-subrc = 0.
  727. i_userexit-modname = wa_modsapa-name.

  728. clear wa_modsapt.
  729. select single modtext into wa_modsapt-modtext from modsapt
  730. where name = wa_modsapa-name
  731. and sprsl = sy-langu.
  732. i_userexit-modtext = wa_modsapt-modtext.

  733. * Get the CMOD project name
  734. clear w_mod.
  735. select single modact~member modact~name modattr~status
  736. modattr~anam modattr~adat
  737. into w_mod
  738. from modact
  739. inner join modattr
  740. on modattr~name = modact~name
  741. where modact~member = wa_modsapa-name
  742. and modact~typ = space.
  743. if sy-subrc = 0.
  744. i_userexit-modattr = w_mod.
  745. endif.
  746. endif.


  747. * BADI data
  748. if i_userexit-type eq 'BADI'.
  749. clear wa_sxs_attr.
  750. select single exit_name into wa_sxs_attr-exit_name from sxs_attr
  751. where exit_name = i_userexit-txt.
  752. if sy-subrc = 0.
  753. i_userexit-modname = i_userexit-txt.
  754. else.
  755. i_userexit-modname = 'Dynamic call'. "#EC NOTEXT
  756. endif.
  757. clear wa_sxs_attrt.
  758. select single text into wa_sxs_attrt-text from sxs_attrt
  759. where exit_name = wa_sxs_attr-exit_name
  760. and sprsl = sy-langu.
  761. i_userexit-modtext = wa_sxs_attrt-text.
  762. endif.

  763. * BADI Implementation
  764. if i_userexit-type eq 'BADI'.
  765. clear sxc_exit.
  766. select COUNT( * ) from sxc_exit where exit_name = i_userexit-txt.
  767. w_cnt = sy-dbcnt.
  768. * determine id BADI is for interal or external use
  769. clear sxs_attr.
  770. select single * from sxs_attr where exit_name = i_userexit-txt.
  771. if sxs_attr-internal = 'X'.
  772. wa_sxs_attrt-text = 'SAP '.
  773. else.
  774. wa_sxs_attrt-text = 'CUST'.
  775. endif.
  776. * concatenate wa_sxs_attrt-text w_cnt into i_userexit-modattr-name
  777. * separated by space.
  778. write wa_sxs_attrt-text to i_userexit-modattr-name.
  779. write w_cnt to i_userexit-modattr-name+5.
  780. endif.

  781. modify i_userexit.
  782. endloop.

  783. * get enhancements via program package
  784. clear wa_tadir.
  785. select single devclass into wa_tadir-devclass from tadir
  786. where pgmid = 'R3TR'
  787. and object = 'PROG'
  788. and obj_name = p_pname.
  789. if sy-subrc = 0.
  790. clear: wa_modsapa, wa_modsapt.
  791. select name from modsapa into wa_modsapa-name
  792. where devclass = wa_tadir-devclass.
  793. select single modtext from modsapt into wa_modsapt-modtext
  794. where name = wa_modsapa-name
  795. and sprsl = sy-langu.

  796. clear i_userexit.
  797. read table i_userexit with key modname = wa_modsapa-name.
  798. if sy-subrc <> 0.
  799. i_userexit-modtext = wa_modsapt-modtext.
  800. i_userexit-type = 'Enhancement'. "#EC NOTEXT
  801. i_userexit-modname = wa_modsapa-name.
  802. i_userexit-txt = 'Determined from program DevClass'."#EC NOTEXT
  803. i_userexit-pname = 'Unknown'. "#EC NOTEXT
  804. append i_userexit.
  805. endif.
  806. endselect.
  807. endif.

  808. * set row colour.
  809. loop at i_userexit.
  810. case i_userexit-type.
  811. when 'BADI'.
  812. i_userexit-colour = 'C601'.
  813. when 'Enhancement'.
  814. i_userexit-colour = 'C501'.
  815. when 'Program Exit'.
  816. i_userexit-colour = 'C401'.
  817. when 'WorkFlow'.
  818. i_userexit-colour = 'C301'.
  819. when 'BusTrEvent'.
  820. i_userexit-colour = 'C201'.
  821. endcase.
  822. modify i_userexit.
  823. endloop.

  824. endform. "GET_ADDITIONAL_DATA

  825. *&--------------------------------------------------------------------&*
  826. *& Form DATA_DISPLAY &*
  827. *&--------------------------------------------------------------------&*
  828. *& &*
  829. *&--------------------------------------------------------------------&*
  830. form data_display.

  831. * data selection message to sap gui
  832. call function 'SAPGUI_PROGRESS_INDICATOR'
  833. destination 'SAPGUI'
  834. keeping logical unit of work
  835. EXPORTING
  836.   text = 'Prepare screen for display' "#EC NOTEXT
  837. EXCEPTIONS
  838.   system_failure
  839.   communication_failure
  840.   . "#EC *

  841. sort i_userexit by type txt modname.
  842. delete adjacent duplicates from i_userexit comparing txt pname modname.

  843. * ensure records selected.
  844. describe table i_userexit lines w_linnum.
  845. if w_linnum = 0.
  846. message s003(g00). "No data records were selected
  847. exit.
  848. endif.

  849. if p_alv = ' '.

  850. * format headings
  851. write: 'Enhancements from main program: ', p_pname.
  852. write: 'Enhancements from TCode: ', p_tcode.
  853. write: 201''.
  854. uline.
  855. format color col_heading.
  856. write: / sy-vline,
  857. (12) c_col1, "Enhanmt Type
  858. sy-vline,
  859. (40) c_col2, "Enhancement
  860. sy-vline,
  861. (30) c_col3, "Program/Include
  862. sy-vline,
  863. (20) c_col4, "Enhancement name
  864. sy-vline,
  865. (40) c_col5, "Enhancement description
  866. sy-vline,
  867. (8) c_col6, "Project
  868. sy-vline,
  869. (1) c_col7, "S
  870. sy-vline,
  871. (12) c_col8, "ChangeName
  872. sy-vline,
  873. (10) c_col9, "ChangeDate
  874. sy-vline.
  875. format reset.
  876. uline.

  877. * format lines
  878. loop at i_userexit.
  879. * set line colour
  880. case i_userexit-type.
  881. when 'Enhancement'.
  882. format color 3 intensified off.
  883. when 'BADI'.
  884. format color 4 intensified off.
  885. when 'BusTrEvent'.
  886. format color 5 intensified off.
  887. when 'Program Exit'.
  888. format color 6 intensified off.
  889. when others.
  890. format reset.
  891. endcase.
  892. write: / sy-vline,
  893. i_userexit-type,
  894. sy-vline,
  895. i_userexit-txt(40),
  896. sy-vline,
  897. i_userexit-pname(30),
  898. sy-vline,
  899. i_userexit-modname(20),
  900. sy-vline,
  901. i_userexit-modtext(40),
  902. sy-vline.

  903. write: i_userexit-modattr-name,
  904. sy-vline,
  905. i_userexit-modattr-status,
  906. sy-vline,
  907. i_userexit-modattr-anam,
  908. sy-vline,
  909. i_userexit-modattr-adat no-zero,
  910. sy-vline.
  911. hide: i_userexit-modname, i_userexit-type, i_userexit-modattr-name.

  912. endloop.
  913. format reset.
  914. uline.

  915. * user-exits from development class of function modules
  916. if p_devc = c_x.
  917. write: /.
  918. write: / c_devc.
  919. write: 201''.
  920. uline (90).
  921. write: 201''.

  922. loop at i_devclass.
  923. clear wa_modsapa.
  924. select name from modsapa into wa_modsapa
  925. where devclass = i_devclass-clas.
  926. select single name modtext into corresponding fields of wa_modsapt
  927. from modsapt
  928. where name = wa_modsapa-name
  929. and sprsl = sy-langu.
  930. format color 3 intensified off.
  931. write: / sy-vline,
  932. (12) 'Enhancement',
  933. sy-vline,
  934. wa_modsapa-name,
  935. sy-vline,
  936. wa_modsapt-modtext,
  937. sy-vline.
  938. endselect.
  939. endloop.
  940. write: 201''.
  941. uline (90).
  942. format reset.
  943. endif.

  944. * display fuction modules used in program
  945. write /.
  946. describe table i_fmodule lines w_linnum.
  947. write: / c_fmod , at 35 w_linnum. "#EC NOTEXT
  948. write: 201''.

  949. if p_func = c_x.
  950. uline (38).
  951. write: 201''.
  952. loop at i_fmodule.
  953. write: sy-vline,
  954. i_fmodule-name,
  955. sy-vline,
  956. i_fmodule-bapi,
  957. sy-vline.
  958. write: 201''.
  959. endloop.
  960. write: 201''.
  961. uline (38).
  962. endif.

  963. * display submit programs used in program
  964. write /.
  965. describe table i_submit lines w_linnum.
  966. write: / c_subm , at 35 w_linnum. "#EC NOTEXT
  967. write: 201''.
  968. if p_subm = c_x.
  969. uline (44).
  970. write: 201''.
  971. loop at i_submit.
  972. write: sy-vline,
  973. i_submit-pname,
  974. sy-vline.
  975. write: 201''.
  976. endloop.
  977. write: 201''.
  978. uline (44).
  979. endif.

  980. * issue message with number of user-exits displayed
  981. describe table i_userexit lines w_linnum.
  982. message s697(56) with w_linnum.

  983. else. " Show in alv format

  984. * issue message with number of user-exits displayed
  985. describe table i_userexit lines w_linnum.
  986. message s697(56) with w_linnum.

  987. * Create field catalog
  988. perform create_field_catalog using 'TYPE' 'T_USEREXIT' ' ' 'Type'.
  989. perform create_field_catalog using 'PNAME' 'T_USEREXIT' ' ' 'Prog?am name'.
  990. perform create_field_catalog using 'TXT' 'T_USEREXIT' ' ' 'Enhancement'.
  991. perform create_field_catalog using 'LEVEL' 'T_USEREXIT' c_x 'Level'.
  992. perform create_field_catalog using 'MODNAME' 'T_USEREXIT' ' ' 'Enhancement name'.
  993. perform create_field_catalog using 'MODTEXT' 'T_USEREXIT' ' ' 'Enhancement text'.
  994. perform create_field_catalog using 'MODATTR-MEMBER' 'T_USEREXIT' c_x 'Member'.
  995. perform create_field_catalog using 'MODATTR-NAME' 'T_USEREXIT' ' ' 'Project'.
  996. perform create_field_catalog using 'MODATTR-STATUS' 'T_USEREXIT' ' ' 'Status'.
  997. perform create_field_catalog using 'MODATTR-ANAM' 'T_USEREXIT' ' ' 'Changed by'.
  998. perform create_field_catalog using 'MODATTR-ADAT' 'T_USEREXIT' ' ' 'Change date'.

  999. * Layout
  1000. clear i_layout.
  1001. i_layout-colwidth_optimize = c_x.
  1002. i_layout-info_fieldname = 'COLOUR'.

  1003. * Sort
  1004. clear i_sort.
  1005. i_sort-fieldname = 'TYPE'.
  1006. i_sort-tabname = 'T_USEREXIT'.
  1007. i_sort-up = c_x.
  1008. append i_sort.

  1009. call function 'REUSE_ALV_GRID_DISPLAY'
  1010. EXPORTING
  1011.   i_callback_program = sy-cprog
  1012.   i_callback_user_command = 'USER_COMMAND'
  1013.   is_layout = i_layout
  1014.   it_fieldcat = i_fieldcat[]
  1015.   it_sort = i_sort[]
  1016.   i_default = c_x
  1017.   i_save = 'A'
  1018.   i_grid_title = w_gridtxt
  1019. TABLES
  1020.   t_outtab = i_userexit.

  1021. endif.

  1022. * issue message with number of user-exits displayed
  1023. describe table i_userexit lines w_linnum.
  1024. message s697(56) with w_linnum.

  1025. endform. "DATA_DISPLAY

  1026. *&---------------------------------------------------------------------&*
  1027. *& Form CREATE_FIELD_CATALOG &*
  1028. *&---------------------------------------------------------------------&*
  1029. form create_field_catalog using p_fieldname
  1030.       p_tabname
  1031.       p_hide
  1032.       p_text.

  1033. i_fieldcat-fieldname = p_fieldname.
  1034. i_fieldcat-tabname = p_tabname.
  1035. i_fieldcat-no_out = p_hide.
  1036. i_fieldcat-seltext_l = p_text.

  1037. append i_fieldcat.

  1038. endform. " CREATE_FIELD_CATALOG

  1039. *&---------------------------------------------------------------------&*
  1040. *& Form CREATE_FIELD_CATALOG &*
  1041. *&---------------------------------------------------------------------&*
  1042. form user_command using r_ucomm like sy-ucomm
  1043.       rs_selfield type slis_selfield.
  1044. read table i_userexit index rs_selfield-tabindex.
  1045. check sy-subrc = 0.
  1046. case r_ucomm.
  1047. when '&IC1'.
  1048. case rs_selfield-sel_tab_field.
  1049. when 'T_USEREXIT-MODNAME'.
  1050. read table i_userexit index rs_selfield-tabindex.
  1051. case i_userexit-type.
  1052. when 'Enhancement'.
  1053. set parameter id 'MON' field i_userexit-modname.
  1054. call transaction 'SMOD'.
  1055. when 'BADI'.
  1056. set parameter id 'EXN' field i_userexit-modname.
  1057. call transaction 'SE18' and skip first screen.
  1058. when 'BusTrEvent'.
  1059. submit rfopfi00 with event = i_userexit-modname(8) and return.
  1060. when others.
  1061. message s030(cj). "Navigation not possible
  1062. endcase.
  1063. when 'T_USEREXIT-MODATTR-NAME'.
  1064. if not i_userexit-modattr-name is initial.
  1065. set parameter id 'MON_KUN' field i_userexit-modattr-name.
  1066. call transaction 'CMOD'.
  1067. else.
  1068. message s030(cj)."Navigation not possible
  1069. endif.
  1070. when others.
  1071. message s030(cj)."Navigation not possible
  1072. endcase.
  1073. endcase.

  1074. endform. "user_command

  1075. *&--------------------------------------------------------------------&*
  1076. *& AT LINE-SELECTION ?*
  1077. *&--------------------------------------------------------------------&*
  1078. at line-selection.

  1079. get cursor field w_fsel.

  1080. case w_fsel.

  1081. when 'I_USEREXIT-MODNAME'.
  1082. case i_userexit-type.
  1083. when 'Enhancement'.
  1084. set parameter id 'MON' field i_userexit-modname.
  1085. call transaction 'SMOD'.
  1086. when 'BADI'.
  1087. set parameter id 'EXN' field i_userexit-modname.
  1088. call transaction 'SE18' and skip first screen.
  1089. when 'BusTrEvent'.
  1090. submit rfopfi00 with event = i_userexit-modname(8) and return.
  1091. when others.
  1092. message s030(cj)."Navigation not possible
  1093. endcase.

  1094. when 'I_USEREXIT-MODATTR-NAME'.
  1095. if not i_userexit-modattr-name is initial.
  1096. set parameter id 'MON_KUN' field i_userexit-modattr-name.
  1097. call transaction 'CMOD'.
  1098. else.
  1099. message s030(cj)."Navigation not possible
  1100. endif.

  1101. when others.
  1102. message s030(cj)."Navigation not possible

  1103. endcase.

  1104. *&--------------------------------------------------------------------&*
  1105. *& AT SELECTION-SCREEN &*
  1106. *&--------------------------------------------------------------------&*
  1107. at selection-screen on radiobutton group rad1.

  1108. * grey-out checkboxes if ALV selected
  1109. at selection-screen output.
  1110. loop at screen.
  1111. if p_alv = c_x.
  1112. if screen-group1 = 'A01'.
  1113. screen-input = '0'.
  1114. modify screen.
  1115. endif.
  1116. else.
  1117. if screen-group1 = 'A01'.
  1118. screen-input = '1'.
  1119. modify screen.
  1120. endif.
  1121. endif.
  1122. endloop.
复制代码
回复

使用道具 举报

ABAP
感谢分享!
回复

使用道具 举报

chowstar
非常實用~~~
回复

使用道具 举报

zzxbat007
感谢分享  收藏了
SAP Business One 凭借单一系统 优化你的整个业务  www.iwilley.com
回复 支持 反对

使用道具 举报

kyle138
感谢分享  收藏了
回复 支持 反对

使用道具 举报

zhongguomao
牛逼,我喜欢。。。
回复

使用道具 举报

xiao
谢谢分享!
回复

使用道具 举报

Anda
感谢分享  收藏了
回复 支持 反对

使用道具 举报

pangpang0827
太棒了!
回复

使用道具 举报

www.sapabap
用不了,一直报错
回复 支持 反对

使用道具 举报

快速回帖

本版积分规则
您需要登录后才可以回帖 登录 | 注册有礼

快速回复 返回顶部 返回列表