Advertisement
Guest User

FM usage report

a guest
Dec 12th, 2014
746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 12.42 KB | None | 0 0
  1. *&---------------------------------------------------------------------*
  2. *& Report  YECC_BC_CHECK_05
  3. *& Аудит использования функциональных модулей
  4. *&---------------------------------------------------------------------*
  5. *& http://entropii.net/?p=2158
  6. *&---------------------------------------------------------------------*
  7.  
  8. report  yecc_bc_check_05.
  9.  
  10. data: begin of gs_report,
  11.         devclass type tadir-devclass,
  12.         fgroup   type rs38l_area,
  13.  
  14.         funcname type tfdir-funcname,
  15.         fmode    type tfdir-fmode,
  16.         pname    type tfdir-pname,
  17.  
  18.         genflag    type tadir-genflag,
  19.         masterlang type tadir-masterlang,
  20.         stext      type tftit-stext,
  21.  
  22.         progname type cross-include,
  23.         shlpname type dd30l-shlpname,
  24.  
  25.         othername type char120,
  26.       end of gs_report.
  27.  
  28. selection-screen begin of block bl0 with frame title text-001.
  29.  
  30. select-options: s_fname for gs_report-funcname.
  31. select-options: s_fgroup for gs_report-fgroup.
  32. select-options: s_devcl for gs_report-devclass.
  33.  
  34. selection-screen end of block bl0.
  35.  
  36. data: gt_report like standard table of gs_report with header line.
  37.  
  38. data: gr_table type ref to cl_salv_table.
  39.  
  40. initialization.
  41.   s_fname-option = 'CP'.
  42.   s_fname-sign   = 'I'.
  43.   s_fname-low    = 'Z*'.
  44.   s_fname-high   = ''.
  45.   append s_fname.
  46.  
  47.   s_fgroup-option = 'CP'.
  48.   s_fgroup-sign   = 'I'.
  49.   s_fgroup-low    = 'Z*'.
  50.   s_fgroup-high   = ''.
  51.   append s_fgroup.
  52.  
  53.   s_devcl-option = 'CP'.
  54.   s_devcl-sign   = 'I'.
  55.   s_devcl-low    = 'Z*'.
  56.   s_devcl-high   = ''.
  57.   append s_devcl.
  58.  
  59. start-of-selection.
  60.  
  61.   perform select_data.
  62.   perform show_alv.
  63.  
  64. end-of-selection.
  65.  
  66. *&---------------------------------------------------------------------*
  67. *&      Form  select_data
  68. *&---------------------------------------------------------------------*
  69. *       text
  70. *----------------------------------------------------------------------*
  71. form select_data.
  72.  
  73.   data: lt_bte type standard table of char20 with header line.
  74.   refresh lt_bte.
  75.   lt_bte = 'TBE31'. append lt_bte. "Publish&Subscribe-СБО: SAP-расширение
  76.   lt_bte = 'TBE32'. append lt_bte. "Publish&Subscribe-СБО: расширения партнеро
  77.   lt_bte = 'TBE34'. append lt_bte. "Publish&Subscribe-СБО: расширения клиентов
  78.   lt_bte = 'TPS31'. append lt_bte. "СБО процесса: альтернативные ФМ SAP
  79.   lt_bte = 'TPS32'. append lt_bte. "СБО процесса: расширения партнера
  80.   lt_bte = 'TPS34'. append lt_bte. "СБО процесса: расширения клиента
  81.  
  82.   ranges: r_pname for tfdir-pname.
  83.   refresh r_pname.
  84.   loop at s_fgroup.
  85.     r_pname-option = s_fgroup-option.
  86.     r_pname-sign   = s_fgroup-sign.
  87.     r_pname-low    = s_fgroup-low.
  88.     r_pname-high   = s_fgroup-high.
  89.  
  90.     if r_pname-low ne space.
  91.       concatenate 'SAPL' r_pname-low into r_pname-low.
  92.     endif.
  93.     if r_pname-high ne space.
  94.       concatenate 'SAPL' r_pname-high into r_pname-high.
  95.     endif.
  96.     append r_pname.
  97.   endloop.
  98.  
  99.   select * from tfdir
  100.     into corresponding fields of table gt_report
  101.     where funcname in s_fname
  102.       and pname in r_pname.
  103.  
  104.   loop at gt_report.
  105.  
  106.     if gt_report-pname(4) = 'SAPL'.
  107.       gt_report-fgroup = gt_report-pname+4(26).
  108.  
  109.       data: ls_tadir type tadir.
  110.       select single * from tadir into ls_tadir
  111.          where pgmid = 'R3TR' and object = 'FUGR' and obj_name = gt_report-fgroup.
  112.       if sy-subrc = 0.
  113.         if ls_tadir-devclass in s_devcl.
  114.           gt_report-devclass = ls_tadir-devclass.
  115.           gt_report-masterlang = ls_tadir-masterlang.
  116.           gt_report-genflag    = ls_tadir-genflag.
  117.         else.
  118.           delete gt_report.
  119.           continue.
  120.         endif.
  121.       endif.
  122.     endif.
  123.  
  124. * Тексты
  125.     select single stext into gt_report-stext from tftit
  126.       where funcname = gt_report-funcname
  127.         and spras = sy-langu.
  128.     if ( sy-subrc ne 0 or gt_report-stext = space ) and gt_report-masterlang ne space and gt_report-masterlang ne sy-langu.
  129.       select single stext into gt_report-stext from tftit
  130.         where funcname = gt_report-funcname
  131.           and spras = gt_report-masterlang. "[TODO] Приоритет английскому языку над немецким: Вход - Рус - Англ - Ориг
  132.     endif.
  133.  
  134. * Обычное использование в программах
  135.     data: lt_cross type standard table of cross with header line.
  136.     refresh lt_cross.
  137.     select * from cross into table lt_cross
  138.       where type = 'F'
  139.         and name = gt_report-funcname.
  140.     loop at lt_cross.
  141.       if lt_cross-include+28(4) = '==FT'.
  142.         delete lt_cross.
  143.       endif.
  144.     endloop.
  145.     if lines( lt_cross ) = 0.
  146.     elseif lines( lt_cross ) = 1.
  147.       read table lt_cross index 1.
  148.       gt_report-progname = lt_cross-include.
  149.     else.
  150.       gt_report-progname = '*'.
  151.     endif.
  152.  
  153. * Средства поиска SE11
  154.     data: lt_dd30l type standard table of dd30l with header line.
  155.     refresh lt_dd30l.
  156.     select * from dd30l
  157.       into table lt_dd30l
  158.       where selmexit = gt_report-funcname and as4local = 'A'.
  159.     if lines( lt_dd30l ) = 0.
  160.     elseif lines( lt_dd30l ) = 1.
  161.       read table lt_dd30l index 1.
  162.       gt_report-shlpname = lt_dd30l-shlpname.
  163.     else.
  164.       gt_report-shlpname = '*'.
  165.     endif.
  166.  
  167. * Open-FI / FIBF
  168.     data: lv_event type tbe34-event.
  169.     loop at lt_bte.
  170.       case lt_bte(3).
  171.         when 'TPS'.   select single procs from (lt_bte) client specified into lv_event where funct = gt_report-funcname.
  172.         when others.  select single event from (lt_bte) client specified into lv_event where funct = gt_report-funcname.
  173.       endcase.
  174.       if sy-subrc = 0.
  175.         concatenate gt_report-othername '+' lt_bte '(' lv_event ')' into gt_report-othername.
  176.       endif.
  177.     endloop.
  178.  
  179. * Деривация ФМ / FMDERIVE
  180.     data: lt_tabadrs type standard table of tabadrs with header line.
  181.     refresh lt_tabadrs.
  182.     select * from tabadrs client specified
  183.       into table lt_tabadrs
  184.       where method = 'FUNC' and param_1 = gt_report-funcname.
  185.     sort lt_tabadrs by abadrenv. delete adjacent duplicates from  lt_tabadrs comparing abadrenv.
  186.     loop at lt_tabadrs.
  187.       concatenate gt_report-othername '+' 'DERIVE' '(' lt_tabadrs-abadrenv ')' into gt_report-othername.
  188.     endloop.
  189.  
  190. *Источники данных / RSA3
  191.     data: lt_roosource type standard table of roosource with header line.
  192.     refresh lt_roosource.
  193.     select * from roosource into table lt_roosource
  194.       where ( exmethod = 'F1' or exmethod = 'F2' or exmethod = 'FS' )
  195.         and extractor = gt_report-funcname.
  196.     loop at lt_roosource.
  197.       concatenate gt_report-othername '+' 'BW' '(' lt_roosource-oltpsource ')' into gt_report-othername.
  198.     endloop.
  199.  
  200. *События бизнес-партнёров / BUBI
  201.     data: lt_tbz1f type standard table of tbz1f with header line.
  202.     refresh lt_tbz1f.
  203.     select * from tbz1f  client specified
  204.       into table lt_tbz1f
  205.       where fname = gt_report-funcname.
  206.     sort lt_tbz1f by ztpkt. delete adjacent duplicates from lt_tbz1f comparing ztpkt.
  207.     loop at lt_tbz1f.
  208.       concatenate gt_report-othername '+' 'BP' '(' lt_tbz1f-ztpkt ')' into gt_report-othername.
  209.     endloop.
  210.  
  211.     data: lt_texc_fld_c type standard table of texc_fld_c with header line.
  212.     refresh lt_texc_fld_c.
  213.     select * from texc_fld_c  client specified
  214.       into table lt_texc_fld_c
  215.       where funcmodule = gt_report-funcname.
  216.     sort lt_texc_fld_c by fieldname. delete adjacent duplicates from lt_texc_fld_c comparing fieldname.
  217.     loop at lt_texc_fld_c.
  218.       concatenate gt_report-othername '+' 'SCASE' '(' lt_texc_fld_c-fieldname ')' into gt_report-othername.
  219.     endloop.
  220.  
  221.     "[QUES][TODO] В анализе настроек перейти от настроек к списку ФМ, в целях улучшения производительности
  222.     modify gt_report.
  223.   endloop.
  224.  
  225.   sort gt_report by devclass fgroup funcname.
  226.  
  227. endform.                                                        "select_data
  228.  
  229. *----------------------------------------------------------------------*
  230. *       CLASS lcl_handle_events DEFINITION
  231. *----------------------------------------------------------------------*
  232. *
  233. *----------------------------------------------------------------------*
  234. class lcl_handle_events definition.
  235.   public section.
  236.     methods:
  237.       on_double_click for event double_click of cl_salv_events_table
  238.         importing row column.
  239. endclass. "lcl_handle_events DEFINITION
  240.  
  241. *----------------------------------------------------------------------*
  242. *       CLASS lcl_handle_events IMPLEMENTATION
  243. *----------------------------------------------------------------------*
  244. *
  245. *----------------------------------------------------------------------*
  246. class lcl_handle_events implementation.
  247.   method on_double_click.
  248.     perform show_cell_info using row column.
  249.   endmethod.                    "on_double_click
  250. endclass. "lcl_handle_events IMPLEMENTATION
  251.  
  252. *&---------------------------------------------------------------------*
  253. *&      Form  show_cell_info
  254. *&---------------------------------------------------------------------*
  255. *       text
  256. *----------------------------------------------------------------------*
  257. *      -->I_ROW      text
  258. *      -->I_COLUMN   text
  259. *----------------------------------------------------------------------*
  260. form show_cell_info using i_row    type i
  261.                           i_column type lvc_fname.
  262.   read table gt_report index i_row.
  263.   check sy-subrc = 0.
  264.  
  265.   perform open_fm using gt_report-funcname.
  266. endform. " show_cell_info
  267.  
  268. *&---------------------------------------------------------------------*
  269. *&      Form  show_alv
  270. *&---------------------------------------------------------------------*
  271. *       text
  272. *----------------------------------------------------------------------*
  273. form show_alv.
  274.  
  275.   call method cl_salv_table=>factory
  276.     importing
  277.       r_salv_table = gr_table
  278.     changing
  279.       t_table      = gt_report[].
  280.  
  281.   data: lo_columns type ref to cl_salv_columns_table.
  282.   lo_columns = gr_table->get_columns( ).
  283.   lo_columns->set_optimize( 'X' ).
  284.  
  285.   data: lo_column  type ref to cl_salv_column_table.
  286.   lo_column ?= lo_columns->get_column( 'PNAME' ). lo_column->set_visible( ' ' ).
  287.  
  288.   lo_column ?= lo_columns->get_column( 'PNAME' ).     lo_column->set_long_text( 'Пул функций' ).
  289.   lo_column ?= lo_columns->get_column( 'OTHERNAME' ). lo_column->set_long_text( 'Другое использование' ).
  290.  
  291.   data: lo_functions type ref to cl_salv_functions_list.
  292.   lo_functions = gr_table->get_functions( ).
  293.   lo_functions->set_all( abap_true ).
  294.  
  295.   data: lo_layout type ref to cl_salv_layout.
  296.   data: ls_key    type salv_s_layout_key.
  297.   lo_layout     = gr_table->get_layout( ).
  298.   ls_key-report = sy-repid.
  299.   lo_layout->set_key( ls_key ).
  300.   lo_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
  301.  
  302.  
  303.   data: gr_events_imp type ref to lcl_handle_events.
  304.   data: lr_events_table type ref to cl_salv_events_table.
  305.   lr_events_table = gr_table->get_event( ).
  306.   create object gr_events_imp.
  307.   set handler gr_events_imp->on_double_click for lr_events_table.
  308.  
  309.   gr_table->display( ).
  310. endform.                                                        "show_alv
  311.  
  312.  
  313. *&---------------------------------------------------------------------*
  314. *&      Form  open_fm
  315. *&---------------------------------------------------------------------*
  316. *       text
  317. *----------------------------------------------------------------------*
  318. form open_fm using iv_funcname.
  319. *  data: begin of bdcdata occurs 0.
  320. *          include structure bdcdata.
  321. *  data: end of bdcdata.
  322. *
  323. *  clear bdcdata.
  324. *  bdcdata-program  = 'SAPLSFUNCTION_BUILDER'.
  325. *  bdcdata-dynpro   = '1008'.
  326. *  bdcdata-dynbegin = 'X'.
  327. *  append bdcdata.
  328. *
  329. *  clear bdcdata.
  330. *  bdcdata-fnam = 'BDC_OKCODE'.
  331. *  bdcdata-fval = '=WB_DISPLAY'.
  332. *  append bdcdata.
  333. *
  334. *  clear bdcdata.
  335. *  bdcdata-fnam = 'RS38L-NAME'.
  336. *  bdcdata-fval = iv_funcname.
  337. *  append bdcdata.
  338. *
  339. *  data: gs_bdc_params type ctu_params.
  340. *  gs_bdc_params-dismode = 'E'.
  341. *  gs_bdc_params-nobinpt ='X'.
  342. *  gs_bdc_params-nobiend = 'X'.
  343.  
  344. *  call transaction 'SE37' using bdcdata options from gs_bdc_params.
  345. *  "странно работает потом
  346.  
  347.   set parameter id 'LIB' field iv_funcname.
  348.   call transaction 'SE37'.
  349.  
  350. endform.                    "open_fm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement