程序可查看系统内开发的程序增强等清单 便于管理开发清单
REPORT zpro_list.
TABLES:usr21,sscrfields..
TYPE-POOLS:slis.
DATA reposrc TYPE reposrc.
TYPES:BEGIN OF ty_text,
zindex TYPE p,
ztext TYPE char100,
zdescribe TYPE char200,
END OF ty_text.
CONSTANTS:lc_x TYPE char01 VALUE 'X',
lc_p TYPE char01 VALUE 'P',
lc_p_t TYPE char10 VALUE '程序',
lc_r TYPE char01 VALUE 'R',
lc_r_t TYPE char10 VALUE 'RFC',
lc_c TYPE char01 VALUE 'C',
lc_c_t TYPE char10 VALUE 'CLASS',
lc_t TYPE char01 VALUE 'T',
lc_t_t TYPE char10 VALUE 'TABLE',
lc_b TYPE char01 VALUE 'B',
lc_b_t TYPE char10 VALUE 'BADI',
lc_e TYPE char01 VALUE 'E',
lc_e_t TYPE char10 VALUE 'CMOD',
lc_o TYPE char01 VALUE 'O',
lc_o_t TYPE char10 VALUE 'ODATA',
lc_prog TYPE char10 VALUE 'PROG',
lc_fugr TYPE char10 VALUE 'FUGR',
lc_r3tr TYPE char10 VALUE 'R3TR',
lc_iwpr TYPE char10 VALUE 'IWPR',
lc_tabl TYPE char10 VALUE 'TABL',
lc_clas TYPE char10 VALUE 'CLAS',
lc_tabclass TYPE char10 VALUE 'TABCLASS'
.
*&------------------------------------------------------------------------------------------------------------------------
*& TEXT
*&------------------------------------------------------------------------------------------------------------------------
CONSTANTS: versionno TYPE string VALUE '1.3.1'.
CONSTANTS: tables TYPE string VALUE 'TABLES'.
CONSTANTS: table TYPE string VALUE 'TABLE'.
CONSTANTS: like TYPE string VALUE 'LIKE'.
CONSTANTS: type TYPE string VALUE 'TYPE'.
CONSTANTS: typerefto TYPE string VALUE 'TYPE REF TO'.
CONSTANTS: structure TYPE string VALUE 'STRUCTURE'.
CONSTANTS: lowstructure TYPE string VALUE 'structure'.
CONSTANTS: occurs TYPE string VALUE 'OCCURS'.
CONSTANTS: function TYPE string VALUE 'FUNCTION'.
CONSTANTS: callfunction TYPE string VALUE ' CALL FUNCTION'.
CONSTANTS: message TYPE string VALUE 'MESSAGE'.
CONSTANTS: include TYPE string VALUE 'INCLUDE'.
CONSTANTS: lowinclude TYPE string VALUE 'include'.
CONSTANTS: destination TYPE string VALUE 'DESTINATION'.
CONSTANTS: is_table TYPE string VALUE 'T'.
CONSTANTS: is_program TYPE string VALUE 'P'.
CONSTANTS: is_screen TYPE string VALUE 'S'.
CONSTANTS: is_guititle TYPE string VALUE 'G'.
CONSTANTS: is_documentation TYPE string VALUE 'D'.
CONSTANTS: is_messageclass TYPE string VALUE 'MC'.
CONSTANTS: is_function TYPE string VALUE 'F'.
CONSTANTS: is_class TYPE string VALUE 'C'.
CONSTANTS: is_method TYPE string VALUE 'M'.
CONSTANTS: asterix TYPE string VALUE '*'.
CONSTANTS: comma TYPE string VALUE ','.
CONSTANTS: period TYPE string VALUE '.'.
CONSTANTS: dash TYPE string VALUE '-'.
CONSTANTS: true TYPE i VALUE 1.
CONSTANTS: false TYPE i VALUE 0.
CONSTANTS: lt TYPE string VALUE '<'.
CONSTANTS: gt TYPE string VALUE '>'.
CONSTANTS: unix TYPE string VALUE 'UNIX'.
CONSTANTS: non_unix TYPE string VALUE 'not UNIX'.
CONSTANTS: background_colour TYPE string VALUE '#FFFFE0'.
CONSTANTS: colour_white TYPE string VALUE '#FFFFFF'.
CONSTANTS: colour_black TYPE string VALUE '#000000'.
CONSTANTS: colour_yellow TYPE string VALUE '#FFFF00'.
CONSTANTS: comment_colour TYPE string VALUE '#0000FF'.
CONSTANTS: htmlextension TYPE string VALUE 'html'.
CONSTANTS: textextension TYPE string VALUE 'txt'.
TYPES: BEGIN OF tdicttablestructure,
fieldname LIKE dd03l-fieldname,
position LIKE dd03l-position,
keyflag LIKE dd03l-keyflag,
rollname LIKE dd03l-rollname,
domname LIKE dd03l-domname,
datatype LIKE dd03l-datatype,
leng LIKE dd03l-leng,
ddtext LIKE dd04t-ddtext,
END OF tdicttablestructure.
TYPES: ttexttable LIKE textpool.
* Message classes
TYPES: BEGIN OF tmessage,
arbgb LIKE t100-arbgb,
stext LIKE t100a-stext,
msgnr LIKE t100-msgnr,
text LIKE t100-text,
END OF tmessage.
* Include program names
TYPES: BEGIN OF tinclude,
includename LIKE trdir-name,
includetitle LIKE tftit-stext,
END OF tinclude.
* Holds a tables attributes + its definition
TYPES: BEGIN OF tdicttable,
tablename LIKE dd03l-tabname,
tabletitle LIKE dd02t-ddtext,
istructure TYPE tdicttablestructure OCCURS 0,
END OF tdicttable.
* GUI titles
TYPES: tguititle LIKE d347t.
* Screen flow.
TYPES: BEGIN OF tscreenflow,
screen LIKE d020s-dnum,
code LIKE d022s-line,
END OF tscreenflow.
TYPES: BEGIN OF tfunction,
functionname LIKE tfdir-funcname,
functiongroup LIKE enlfdir-area,
includenumber LIKE tfdir-include,
functionmaininclude LIKE tfdir-funcname,
functiontitle LIKE tftit-stext,
topincludename LIKE tfdir-funcname,
progname LIKE tfdir-pname,
programlinkname LIKE tfdir-pname,
messageclass LIKE t100-arbgb,
itextelements TYPE ttexttable OCCURS 0,
iselectiontexts TYPE ttexttable OCCURS 0,
imessages TYPE tmessage OCCURS 0,
iincludes TYPE tinclude OCCURS 0,
idictstruct TYPE tdicttable OCCURS 0,
iguititle TYPE tguititle OCCURS 0,
iscreenflow TYPE tscreenflow OCCURS 0,
END OF tfunction.
TYPES: BEGIN OF tprogram,
progname LIKE trdir-name,
programtitle LIKE tftit-stext,
subc LIKE trdir-subc,
messageclass LIKE t100-arbgb,
imessages TYPE tmessage OCCURS 0,
itextelements TYPE ttexttable OCCURS 0,
iselectiontexts TYPE ttexttable OCCURS 0,
iguititle TYPE tguititle OCCURS 0,
iscreenflow TYPE tscreenflow OCCURS 0,
iincludes TYPE tinclude OCCURS 0,
idictstruct TYPE tdicttable OCCURS 0,
END OF tprogram.
DATA: objruntimeerror TYPE REF TO cx_root.
DATA: dumiincludes TYPE STANDARD TABLE OF tinclude.
DATA: dumiguititle TYPE STANDARD TABLE OF tguititle.
DATA: dumitexttab TYPE STANDARD TABLE OF ttexttable.
DATA: idictionary TYPE STANDARD TABLE OF tdicttable WITH HEADER LINE.
DATA: dumidictstructure TYPE STANDARD TABLE OF tdicttablestructure.
DATA: imessages TYPE STANDARD TABLE OF tmessage WITH HEADER LINE.
DATA: iprograms TYPE STANDARD TABLE OF tprogram WITH HEADER LINE.
RANGES: sofunctionname FOR tfdir-funcname.
RANGES: sofunctiongroup FOR enlfdir-area.
RANGES: soauthor FOR usr02-bname.
RANGES: soprogramname FOR trdir-name.
*&------------------------------------------------------------------------------------------------------------------------
*& TEXT
*&------------------------------------------------------------------------------------------------------------------------
** 定义布局和样式
DATA: w_layout TYPE lvc_s_layo,
t_fieldcat TYPE lvc_t_fcat.
DATA :gt_events TYPE slis_t_event,
gv_grid TYPE REF TO cl_gui_alv_grid. " ALV 对象
TYPES: BEGIN OF ty_data,
zzbox TYPE char01,
name TYPE dwinactiv-obj_name, "识别名称
progname TYPE reposrc-progname, "SE38程序名
funcname TYPE tftit-funcname, "SE37程序名
clsname TYPE seoclassdf-clsname , "class名
pname TYPE tfdir-pname, "接口程序名
projekt TYPE modattr-name, "客户出口名称
cust_inc TYPE tadir-obj_name, "客户出口INCLUDE
devclass TYPE tadir-devclass, "Package
fctgrp TYPE rs38l-area, "函数组
mod TYPE tfdir-pname, "客户原始的SMOD
imp_name TYPE sxc_attr-imp_name, "BADI
tabclass TYPE dd02vv-tabclass, "表类型
ddtext TYPE dd07t-ddtext, "表类型描述fctgrp
text TYPE trdirt-text, "描述
r3state TYPE reposrc-r3state, "状态
codetype TYPE char1, "类型 (P se38 R SE37 C SE24 T SE11 B SE19 E CMOD O SEGW)
codetext TYPE char10, "类型 (P se38 R SE37 C SE24 T SE11 B SE19 E CMOD O SEGW)
cnam TYPE reposrc-cnam, "创建人
cdat TYPE reposrc-cdat, "创建日期
ctime TYPE reposrc-utime, "创建时间
unam TYPE reposrc-unam, "最后修改人
udat TYPE reposrc-udat, "最后修改日期
utime TYPE reposrc-utime, "最后修改时间
creation_time TYPE /iwbep/i_sbd_pr-creation_time, "创建时间戳
last_chg_time TYPE /iwbep/i_sbd_pr-last_chg_time, "最后修改时间戳
* text TYPE trdirt-text,
END OF ty_data.
DATA:ls_sbd_fp TYPE /iwbep/i_sbd_fp, "odata数据处理工作区
ls_data TYPE ty_data,
gs_data TYPE ty_data,
gt_data TYPE TABLE OF ty_data, "
lt_data TYPE TABLE OF ty_data,
lt_text TYPE TABLE OF ty_text,
ls_text TYPE ty_text,
lt_data_p TYPE TABLE OF ty_data, "se38程序
lt_data_r TYPE TABLE OF ty_data, "SE37程序
lt_data_c TYPE TABLE OF ty_data, "SE24程序
lt_data_t TYPE TABLE OF ty_data, "table
lt_data_b TYPE TABLE OF ty_data, "BADI
lt_data_e TYPE TABLE OF ty_data, "EXIT
lt_data_o TYPE TABLE OF ty_data, "ODATA
lt_data_temp TYPE TABLE OF ty_data, "中间处理表
lt_sbd_fp TYPE TABLE OF /iwbep/i_sbd_fp. "odata数据处理表
DATA:lt_dwinactiv TYPE TABLE OF dwinactiv,
lt_tstc TYPE TABLE OF tstc,
lt_sxc_attrt TYPE TABLE OF sxc_attrt,
ls_sxc_attrt TYPE sxc_attrt,
lt_tftit TYPE TABLE OF tftit,
ls_tftit TYPE tftit,
lt_trdirt TYPE TABLE OF trdirt,
ls_trdirt TYPE trdirt.
DATA: ifunctions TYPE STANDARD TABLE OF tfunction WITH HEADER LINE.
SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE title1.
SELECT-OPTIONS : s_name FOR reposrc-progname, "程序名
s_r3st FOR reposrc-r3state, "程序状态
s_cnam FOR usr21-bname, "创建者
s_unam FOR reposrc-unam. "最后修改者
* s_type FOR reposrc-varcl . "程序类信息 P se38程序 R SE37 程序 C SE24程序 T table(还没有加)
SELECTION-SCREEN END OF BLOCK blk.
SELECTION-SCREEN BEGIN OF BLOCK b2k WITH FRAME TITLE title2.
PARAMETERS: p_p AS CHECKBOX,
p_r AS CHECKBOX,
p_c AS CHECKBOX,
p_t AS CHECKBOX,
p_b AS CHECKBOX,
p_e AS CHECKBOX,
p_o AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b2k.
SELECTION-SCREEN BEGIN OF BLOCK b3k WITH FRAME TITLE title3.
PARAMETERS: p_x1 RADIOBUTTON GROUP gp1 DEFAULT 'X',
p_x2 RADIOBUTTON GROUP gp1.
SELECTION-SCREEN END OF BLOCK b3k.
INITIALIZATION.
%_s_name_%_app_%-text = '程序名'.
%_s_r3st_%_app_%-text = '程序状态'.
%_s_cnam_%_app_%-text = '创建者'.
%_s_unam_%_app_%-text = '最后修改者'.
%_p_p_%_app_%-text = '报表'.
%_p_r_%_app_%-text = '接口'.
%_p_c_%_app_%-text = 'CLASS'.
%_p_t_%_app_%-text = '表'.
%_p_b_%_app_%-text = 'BADI'.
%_p_e_%_app_%-text = 'CMOD'.
%_p_o_%_app_%-text = 'ODATA'.
%_p_x1_%_app_%-text = '查询'.
%_p_x2_%_app_%-text = '小功能合集'.
sscrfields-functxt_01 = '@0S@使用说明'.
sscrfields-functxt_02 = '@0S@小功能合集内容'.
title1 = '条件选择'.
title2 = '显示类型'.
title3 = '功能选择'.
AT SELECTION-SCREEN.
IF sscrfields-ucomm = 'FC01'.
MESSAGE '请谨慎使用本程序' TYPE 'I'.
ENDIF.
IF sscrfields-ucomm = 'FC02'.
MESSAGE '使用sql查询数据、视图转换查询' TYPE 'I'.
ENDIF.
START-OF-SELECTION. "获取数据"
PERFORM get_data. "获取数据
END-OF-SELECTION. "执行完后“
PERFORM frm_alv_show. " alV显示设置
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_data .
IF p_p = lc_x.
PERFORM get_progname.
APPEND LINES OF lt_data_p[] TO lt_data[].
ENDIF.
IF p_r = lc_x.
PERFORM get_rfc.
APPEND LINES OF lt_data_r[] TO lt_data[].
ENDIF.
IF p_c = lc_x.
PERFORM get_class.
APPEND LINES OF lt_data_c[] TO lt_data[].
ENDIF.
IF p_t = lc_x.
PERFORM get_table.
APPEND LINES OF lt_data_t[] TO lt_data[].
ENDIF.
IF p_b = lc_x.
PERFORM get_badi.
APPEND LINES OF lt_data_b[] TO lt_data[].
ENDIF.
IF p_e = lc_x.
PERFORM get_exit.
APPEND LINES OF lt_data_e[] TO lt_data[].
ENDIF.
IF p_o = lc_x.
PERFORM get_odata.
APPEND LINES OF lt_data_o[] TO lt_data[].
ENDIF.
DELETE lt_data WHERE unam NOT IN s_unam.
IF lt_data[] IS INITIAL.
MESSAGE '选择数据为空,请检查输入' TYPE 'E' .
ENDIF.
ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form frm_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_layout .
w_layout-zebra = 'X'.
w_layout-box_fname = 'ZZBOX'.
ENDFORM. " frm_layout
*&---------------------------------------------------------------------*
*& Form frm_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_fieldcat .
DATA:lv_p_name TYPE char256.
IF p_r = lc_x.
lv_p_name = '接口'.
ENDIF.
IF p_e = lc_x.
IF lv_p_name IS INITIAL.
lv_p_name = 'CMOD'.
ELSE.
lv_p_name = lv_p_name && '/CMOD'.
ENDIF.
ENDIF.
PERFORM frm_cell_fldcat USING 'NAME' '程序名(双击跳转TCODE)' '' 'X' '' ''.
IF lv_p_name IS NOT INITIAL.
PERFORM frm_cell_fldcat USING 'PNAME' lv_p_name '' '' '' ''.
ENDIF.
IF p_r IS NOT INITIAL.
PERFORM frm_cell_fldcat USING 'FCTGRP' '函数组' '' '' '' ''.
ENDIF.
PERFORM frm_cell_fldcat USING 'TEXT' '描述(双击获取详细信息)' '' '' '' ''.
PERFORM frm_cell_fldcat USING 'R3STATE' '状态' '' '' '' ''.
IF p_t = lc_x.
PERFORM frm_cell_fldcat USING 'DDTEXT' '表类型' '' '' '' ''.
ENDIF.
* PERFORM frm_cell_fldcat USING 'CODETYPE' '类型' '' '' '' ''.
PERFORM frm_cell_fldcat USING 'CODETEXT' '类型描述' '' '' '' ''.
PERFORM frm_cell_fldcat USING 'DEVCLASS' 'Package' '' '' '' ''.
PERFORM frm_cell_fldcat USING 'CNAM' '创建人' '' '' '' ''.
PERFORM frm_cell_fldcat USING 'CDAT' '创建日期' '' '' '' ''.
PERFORM frm_cell_fldcat USING 'UNAM' '最后修改人' '' '' '' ''.
PERFORM frm_cell_fldcat USING 'UDAT' '最后修改日期' '' '' '' ''.
PERFORM frm_cell_fldcat USING 'UTIME' '最后修改时间' '' '' '' ''.
ENDFORM. "frm_fieldcat
*&---------------------------------------------------------------------*
*& Form frm_display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_display.
DATA: lw_grid_settings TYPE lvc_s_glay.
lw_grid_settings-edt_cll_cb = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
is_layout_lvc = w_layout
it_fieldcat_lvc = t_fieldcat
i_grid_settings = lw_grid_settings
i_callback_user_command = 'FRM_USER_COMMAND'
* i_callback_pf_status_set = 'FRM_STATUS_SET'
it_events = gt_events[] "分屏显示
TABLES
t_outtab = lt_data.
ENDFORM. " frm_display
*&---------------------------------------------------------------------*
*& Form frm_cell_fldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0181 text
* -->P_0182 text
* -->P_0183 text
* -->P_0184 text
* -->P_0185 text
* -->P_0186 text
*----------------------------------------------------------------------*
FORM frm_cell_fldcat USING u_fieldname
u_text
u_edit
u_no_zero
u_reftable
u_reffield.
DATA: lw_fieldcat TYPE lvc_s_fcat.
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = u_fieldname.
lw_fieldcat-scrtext_l = u_text.
lw_fieldcat-scrtext_m = u_text.
lw_fieldcat-scrtext_s = u_text.
lw_fieldcat-edit = u_edit.
lw_fieldcat-no_zero = u_no_zero.
lw_fieldcat-ref_table = u_reftable.
lw_fieldcat-ref_field = u_reffield.
lw_fieldcat-col_opt = 'X'.
APPEND lw_fieldcat TO t_fieldcat.
ENDFORM. " frm_cell_fldcat
*&---------------------------------------------------------------------*
*& Form frm_user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_UCOMM text
* -->P_RS_SELFIELD text
*----------------------------------------------------------------------*
FORM frm_user_command USING p_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: ref TYPE REF TO cl_gui_alv_grid.
CLEAR:lt_text[].
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref.
CALL METHOD ref->check_changed_data.
* save_ok = p_ucomm.
DATA:fid(20).
DATA:num(20).
CASE p_ucomm.
WHEN '&IC1'.
num = rs_selfield-tabindex .
CASE rs_selfield-fieldname.
WHEN 'TEXT'. "获取帮助开发消息
READ TABLE lt_data INTO ls_data INDEX num.
IF sy-subrc = 0.
IF ls_data-codetype = 'R'.
"接口
PERFORM get_rfc_text TABLES lt_text[] CHANGING ls_data-name.
ELSEIF ls_data-codetype = 'P'.
PERFORM get_program_text TABLES lt_text[] CHANGING ls_data-name.
ELSEIF ls_data-codetype = 'C'.
PERFORM get_class_text TABLES lt_text[] CHANGING ls_data-name.
ELSEIF ls_data-codetype = 'T'.
PERFORM get_table_text TABLES lt_text[] CHANGING ls_data-name.
ELSEIF ls_data-codetype = 'B'.
PERFORM get_badi_text TABLES lt_text[] CHANGING ls_data-name.
ELSEIF ls_data-codetype = 'E'.
PERFORM get_exit_text TABLES lt_text[] CHANGING ls_data-name.
ELSEIF ls_data-codetype = 'O'.
PERFORM get_odata_text TABLES lt_text[] CHANGING ls_data-name.
ELSE.
MESSAGE '暂时不支持此类型' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
cl_demo_output=>display( lt_text[] ).
ENDIF.
WHEN 'NAME'. "根据名字跳转到对应的程序中
"双击跳转至对应的程序中。
IF rs_selfield-tabindex IS NOT INITIAL.
num = rs_selfield-tabindex .
READ TABLE lt_data INTO ls_data INDEX num.
IF sy-subrc = 0.
IF ls_data-codetype = 'R'.
SET PARAMETER ID 'LIB' FIELD ls_data-name.
CALL TRANSACTION 'SE37'. "AND SKIP FIRST SCREEN.
ELSEIF ls_data-codetype = 'P'.
SET PARAMETER ID 'RID' FIELD ls_data-name.
CALL TRANSACTION 'SE38'.
ELSEIF ls_data-codetype = 'C'.
SET PARAMETER ID 'CLASS' FIELD ls_data-name.
CALL TRANSACTION 'SE24' .
ELSEIF ls_data-codetype = 'T'.
IF ls_data-tabclass = 'INTTAB'. "结构 由于结构可能名字超过表格,单端传值
SET PARAMETER ID 'DTYP' FIELD ls_data-name.
ELSE.
SET PARAMETER ID 'DTB' FIELD ls_data-name.
ENDIF.
CALL TRANSACTION 'SE11'.
ELSEIF ls_data-codetype = 'B'.
SET PARAMETER ID 'IMN' FIELD ls_data-name.
CALL TRANSACTION 'SE19'.
ELSEIF ls_data-codetype = 'E'.
SET PARAMETER ID 'MON_KUN' FIELD ls_data-pname.
CALL TRANSACTION 'CMOD' .
ELSEIF ls_data-codetype = 'O'.
SELECT * FROM /iwbep/i_sbd_fp INTO TABLE lt_sbd_fp WHERE uname = sy-uname AND project = ls_data-name.
IF sy-subrc <> 0.
CLEAR ls_sbd_fp.
ls_sbd_fp-uname = sy-uname.
ls_sbd_fp-project = ls_data-name.
INSERT /iwbep/i_sbd_fp FROM ls_sbd_fp.
COMMIT WORK AND WAIT.
ENDIF.
CALL TRANSACTION 'SEGW'.
ELSE.
MESSAGE '暂时不支持此类型' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
ENDIF.
ENDIF.
case 'TABCLASS'."如果是表类型的 检查表的看是否可以使用SE16N查询数据
ENDCASE.
WHEN OTHERS.
MESSAGE '没有开发功能' TYPE 'S' DISPLAY LIKE 'E'.
"gt_alv-top_line = top_line.
ENDCASE.
* PERFORM frm_refresh_alv.
rs_selfield-refresh = 'X'.
ENDCASE.
ENDFORM. "frm_user_command
*&---------------------------------------------------------------------*
*& Form FRM_REFRESH_ALV
*&---------------------------------------------------------------------*
* text 刷新程序
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_refresh_alv .
DATA: ls_stable TYPE lvc_s_stbl. "刷新稳定
ls_stable-row = 'X'.
ls_stable-col = 'X'.
CALL METHOD gv_grid->refresh_table_display "刷新方法
EXPORTING
is_stable = ls_stable
i_soft_refresh = 'X'
EXCEPTIONS
finished = 1
OTHERS = 2.
ENDFORM. " FRM_REFRESH_ALV
FORM frm_alv_show .
PERFORM get_events.
PERFORM frm_layout. " 设置layout
PERFORM frm_fieldcat. " 设置fieldcat
PERFORM frm_display. " 调用函数显示alv
ENDFORM. " FRM_ALV_SHOW
*&---------------------------------------------------------------------*
*& Form GET_EVENTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_events .
DATA w_event TYPE LINE OF slis_t_event.
w_event-name = slis_ev_top_of_page.
w_event-form = 'FRM_TOP_OF_PAGE'.
APPEND w_event TO gt_events.
ENDFORM. " GET_EVENTS
*&---------------------------------------------------------------------*
*& Form FRM_TOP_OF_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_top_of_page .
DATA:lv_total_lines TYPE char6,
lv_p_lines TYPE char6,
lv_r_lines TYPE char6,
lv_t_lines TYPE char6,
lv_c_lines TYPE char6,
lv_b_lines TYPE char6,
lv_e_lines TYPE char6,
lv_o_lines TYPE char6.
DATA:lv_info TYPE char256.
lv_p_lines = lines( lt_data_p ).
lv_r_lines = lines( lt_data_r ).
lv_c_lines = lines( lt_data_c ).
lv_t_lines = lines( lt_data_t ).
lv_b_lines = lines( lt_data_b ).
lv_e_lines = lines( lt_data_e ).
lv_o_lines = lines( lt_data_o ).
CONDENSE lv_p_lines NO-GAPS.
CONDENSE lv_r_lines NO-GAPS.
CONDENSE lv_c_lines NO-GAPS.
CONDENSE lv_t_lines NO-GAPS.
CONDENSE lv_b_lines NO-GAPS.
CONDENSE lv_e_lines NO-GAPS.
CONDENSE lv_o_lines NO-GAPS.
DATA: ls_comment TYPE slis_listheader,
lt_comment TYPE slis_t_listheader.
ls_comment-typ = 'H'.
lv_total_lines = lv_p_lines + lv_r_lines + lv_c_lines + lv_t_lines + lv_b_lines + lv_e_lines + lv_o_lines.
CONCATENATE '总数:' lv_total_lines INTO ls_comment-info.
APPEND ls_comment TO lt_comment.
ls_comment-typ = 'S'.
CLEAR lv_info.
IF lv_p_lines <> 0 .
CONCATENATE '程序:' lv_p_lines INTO lv_info.
ENDIF.
IF lv_r_lines <> 0 .
IF ( strlen( lv_info ) + strlen( lv_r_lines ) ) > 40 .
ls_comment-info = lv_info.
APPEND ls_comment TO lt_comment.
CLEAR:lv_info.
lv_info = |RFC:{ lv_r_lines }|.
ELSE.
lv_info = |{ lv_info } RFC:{ lv_r_lines }|.
ENDIF.
* CONCATENATE lv_info space 'RFC:' lv_r_lines INTO lv_info.
ENDIF.
IF lv_c_lines <> 0 .
IF ( strlen( lv_info ) + strlen( lv_c_lines ) ) > 40 .
ls_comment-info = lv_info.
APPEND ls_comment TO lt_comment.
CLEAR:lv_info.
lv_info = |CLASS:{ lv_c_lines }|.
ELSE.
lv_info = |{ lv_info } CLASS:{ lv_c_lines }|.
ENDIF.
* CONCATENATE lv_info space 'CLASS:' lv_c_lines INTO lv_info.
ENDIF.
IF lv_t_lines <> 0 .
IF ( strlen( lv_info ) + strlen( lv_t_lines ) ) > 40 .
ls_comment-info = lv_info.
APPEND ls_comment TO lt_comment.
CLEAR:lv_info.
lv_info = |TABLE:{ lv_t_lines }|.
ELSE.
lv_info = |{ lv_info } TABLE:{ lv_t_lines }|.
ENDIF.
* CONCATENATE lv_info 'TABLE:' lv_t_lines INTO lv_info.
ENDIF.
IF lv_b_lines <> 0 .
IF ( strlen( lv_info ) + strlen( lv_b_lines ) ) > 40 .
ls_comment-info = lv_info.
APPEND ls_comment TO lt_comment.
CLEAR:lv_info.
lv_info = |BADI:{ lv_b_lines }|.
ELSE.
lv_info = |{ lv_info } BADI:{ lv_b_lines }|.
ENDIF.
* CONCATENATE lv_info space 'BADI:' lv_b_lines INTO lv_info.
ENDIF.
IF lv_e_lines <> 0 .
IF ( strlen( lv_info ) + strlen( lv_e_lines ) ) > 40 .
ls_comment-info = lv_info.
APPEND ls_comment TO lt_comment.
CLEAR:lv_info.
lv_info = |EXIT:{ lv_e_lines }|.
ELSE.
lv_info = |{ lv_info } EXIT:{ lv_e_lines }|.
ENDIF.
* CONCATENATE lv_info space 'EXIT:' lv_e_lines INTO lv_info.
ENDIF.
IF lv_o_lines <> 0 .
IF ( strlen( lv_info ) + strlen( lv_o_lines ) ) > 40 .
ls_comment-info = lv_info.
APPEND ls_comment TO lt_comment.
CLEAR:lv_info.
lv_info = |ODATA:{ lv_o_lines }|.
ELSE.
lv_info = |{ lv_info } ODATA:{ lv_o_lines }|.
ENDIF.
* CONCATENATE lv_info space 'ODATA:' lv_o_lines INTO lv_info.
ENDIF.
IF lv_info IS NOT INITIAL .
ls_comment-info = lv_info.
APPEND ls_comment TO lt_comment.
ENDIF.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = lt_comment.
ENDFORM. " FRM_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form GET_PROGNAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_progname .
"获取SE38程序
SELECT progname AS name
progname
r3state
cnam
cdat
unam
udat
utime
text
devclass
INTO CORRESPONDING FIELDS OF TABLE lt_data_p
FROM reposrc LEFT JOIN trdirt ON reposrc~progname = trdirt~name
AND sprsl = sy-langu
JOIN tadir ON reposrc~progname = tadir~obj_name
AND object = lc_prog
AND pgmid = lc_r3tr
WHERE ( progname LIKE 'Z%' OR progname LIKE 'Y%' )
AND rmand <> ''
AND dbna = ''
AND cnam <> 'SAP'
AND progname IN s_name
AND r3state IN s_r3st
AND cnam IN s_cnam.
SELECT * INTO TABLE lt_trdirt FROM trdirt FOR ALL ENTRIES IN lt_data_p WHERE name = lt_data_p-progname.
SORT lt_trdirt BY name.
LOOP AT lt_data_p ASSIGNING FIELD-SYMBOL(<fs_data>).
"补充其他语言的描述
IF <fs_data>-text IS INITIAL.
READ TABLE lt_trdirt INTO ls_trdirt WITH KEY name = <fs_data>-progname BINARY SEARCH.
IF sy-subrc = 0.
<fs_data>-text = ls_trdirt-text.
ENDIF.
ENDIF.
<fs_data>-codetype = lc_p.
<fs_data>-codetext = lc_p_t.
ENDLOOP.
CLEAR lt_data_temp[].
MOVE-CORRESPONDING lt_data_p[] TO lt_data_temp[].
CLEAR lt_data_p[].
"去除未激活表
SELECT object
obj_name
uname
INTO CORRESPONDING FIELDS OF TABLE lt_dwinactiv
FROM dwinactiv
FOR ALL ENTRIES IN lt_data_temp
WHERE obj_name = lt_data_temp-name.
SORT lt_dwinactiv BY object.
* CLEAR lt_data[].
LOOP AT lt_data_temp INTO ls_data.
"判断是否激活,没激活不展示
READ TABLE lt_dwinactiv TRANSPORTING NO FIELDS WITH KEY object = ls_data-name BINARY SEARCH.
IF sy-subrc <> 0.
APPEND ls_data TO lt_data_p.
ENDIF.
CLEAR ls_data.
ENDLOOP.
ENDFORM. " GET_PROGNAME
*&---------------------------------------------------------------------*
*& Form GET_RFC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_rfc .
TYPES:BEGIN OF ty_tfdir,
funcname TYPE tfdir-funcname,
pname TYPE tfdir-pname,
include TYPE tfdir-include,
progname TYPE reposrc-progname,
END OF ty_tfdir,
BEGIN OF ty_reposrc_rfc,
progname TYPE reposrc-progname,
cnam TYPE reposrc-cnam,
cdat TYPE reposrc-cdat,
unam TYPE reposrc-unam,
udat TYPE reposrc-udat,
utime TYPE reposrc-utime,
END OF ty_reposrc_rfc.
DATA:lt_tfdir TYPE TABLE OF ty_tfdir,
ls_tfdir TYPE ty_tfdir,
lt_reposrc_rfc TYPE TABLE OF ty_reposrc_rfc,
ls_reposrc_rfc TYPE ty_reposrc_rfc.
"获取SE37程序
SELECT tfdir~funcname AS name
tfdir~funcname
pname
cnam
cdat
unam
udat
utime
tftit~stext AS text
* devclass
INTO CORRESPONDING FIELDS OF TABLE lt_data_r
FROM tfdir JOIN reposrc ON tfdir~pname = reposrc~progname
LEFT JOIN tftit ON tfdir~funcname = tftit~funcname
AND stext = sy-langu
* JOIN tadir ON tfdir~PNAME = tadir~obj_name
* AND object = lc_FUGR
* AND pgmid = lc_R3TR
WHERE ( tfdir~funcname LIKE 'Z%' OR tfdir~funcname LIKE 'Y%' )
AND cnam <> 'SAP'
AND tfdir~funcname IN s_name
AND r3state IN s_r3st
AND cnam IN s_cnam
* AND UNAM IN S_UNAM
.
IF lt_data_r[] IS NOT INITIAL.
SELECT funcname
pname
include
INTO CORRESPONDING FIELDS OF TABLE lt_tfdir
FROM tfdir
FOR ALL ENTRIES IN lt_data_r
WHERE funcname = lt_data_r-funcname.
LOOP AT lt_tfdir ASSIGNING FIELD-SYMBOL(<fs_tfdir>).
<fs_tfdir>-progname = substring_after( val = <fs_tfdir>-pname sub = 'SAP' ) && 'U' && <fs_tfdir>-include.
ENDLOOP.
IF lt_tfdir[] IS NOT INITIAL..
SELECT progname
cnam
cdat
unam
udat
utime
INTO TABLE lt_reposrc_rfc
FROM reposrc
FOR ALL ENTRIES IN lt_tfdir
WHERE progname = lt_tfdir-progname.
ENDIF.
ENDIF.
SELECT * INTO TABLE lt_tftit FROM tftit FOR ALL ENTRIES IN lt_data_r WHERE funcname = lt_data_r-funcname.
SORT lt_tftit BY funcname.
DATA:lv_fctname TYPE rs38l-name,
lv_fctgrp TYPE rs38l-area.
LOOP AT lt_data_r ASSIGNING FIELD-SYMBOL(<fs_data>).
CLEAR :lv_fctname ,lv_fctgrp.
lv_fctname = <fs_data>-funcname.
CALL FUNCTION 'FUNCTION_EXISTS'
EXPORTING
funcname = lv_fctname
IMPORTING
group = lv_fctgrp
EXCEPTIONS
function_not_exist = 01.
<fs_data>-fctgrp = lv_fctgrp.
SELECT SINGLE devclass INTO <fs_data>-devclass FROM tadir WHERE pgmid = lc_r3tr AND object = lc_fugr AND obj_name = lv_fctgrp.
"更新RFC信息
READ TABLE lt_tfdir INTO ls_tfdir WITH KEY funcname = <fs_data>-funcname.
IF sy-subrc = 0.
READ TABLE lt_reposrc_rfc INTO ls_reposrc_rfc WITH KEY progname = ls_tfdir-progname.
IF sy-subrc = 0.
<fs_data>-cnam = ls_reposrc_rfc-cnam.
<fs_data>-cdat = ls_reposrc_rfc-cdat.
<fs_data>-unam = ls_reposrc_rfc-unam.
<fs_data>-udat = ls_reposrc_rfc-udat.
<fs_data>-utime = ls_reposrc_rfc-utime.
ENDIF.
ENDIF.
"补充其他语言的描述
IF <fs_data>-text IS INITIAL.
READ TABLE lt_tftit INTO ls_tftit WITH KEY funcname = <fs_data>-funcname BINARY SEARCH.
IF sy-subrc = 0.
<fs_data>-text = ls_tftit-stext.
ENDIF.
ENDIF.
<fs_data>-codetype = lc_r.
<fs_data>-codetext = lc_r_t.
ENDLOOP.
CLEAR lt_data_temp[].
MOVE-CORRESPONDING lt_data_r[] TO lt_data_temp[].
CLEAR lt_data_r[].
"去除未激活表
SELECT object
obj_name
uname
INTO CORRESPONDING FIELDS OF TABLE lt_dwinactiv
FROM dwinactiv
FOR ALL ENTRIES IN lt_data_temp
WHERE obj_name = lt_data_temp-name.
SORT lt_dwinactiv BY object.
* CLEAR lt_data[].
LOOP AT lt_data_temp INTO ls_data.
"判断是否激活,没激活不展示
READ TABLE lt_dwinactiv TRANSPORTING NO FIELDS WITH KEY object = ls_data-name BINARY SEARCH.
IF sy-subrc <> 0.
APPEND ls_data TO lt_data_r.
ENDIF.
CLEAR ls_data.
ENDLOOP.
ENDFORM. " GET_RFC
*&---------------------------------------------------------------------*
*& Form GET_CLASS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_class .
"获取class
SELECT seoclassdf~clsname AS name
seoclassdf~clsname
seoclassdf~author AS cnam
createdon AS cdat
changedby AS unam
changedon AS udat
seoclasstx~descript AS text
devclass
INTO CORRESPONDING FIELDS OF TABLE lt_data_c
FROM seoclassdf LEFT JOIN seoclasstx ON seoclassdf~clsname = seoclasstx~clsname
AND langu = sy-langu
JOIN tadir ON seoclassdf~clsname = tadir~obj_name
AND object = lc_clas
AND pgmid = lc_r3tr
WHERE ( seoclassdf~clsname LIKE 'Z%' OR seoclassdf~clsname LIKE 'Y%' )
AND seoclassdf~clsname IN s_name
AND seoclassdf~author IN s_cnam
.
LOOP AT lt_data_c ASSIGNING FIELD-SYMBOL(<fs_data>).
<fs_data>-codetype = lc_c.
<fs_data>-codetext = lc_c_t.
ENDLOOP.
ENDFORM. " GET_CLASS
*&---------------------------------------------------------------------*
*& Form GET_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_table .
"获取SE11表
SELECT tabname AS name
* tfdir~funcname
* pname
as4user AS cnam
as4date AS cdat
as4time AS ctime
tabclass
* unam
* udat
* utime
dd07t~ddtext
dd02vv~ddtext AS text
devclass
INTO CORRESPONDING FIELDS OF TABLE lt_data_t
FROM dd02vv JOIN dd07t ON dd02vv~tabclass = dd07t~domvalue_l
AND domname = lc_tabclass
AND dd07t~ddlanguage = sy-langu
JOIN tadir ON dd02vv~tabname = tadir~obj_name
AND object = lc_tabl
AND pgmid = lc_r3tr
WHERE ( tabname LIKE 'Z%' OR tabname LIKE 'Y%' )
AND tabname IN s_name
AND as4user IN s_cnam
.
*
* SELECT * INTO TABLE lt_tftit FROM tftit FOR ALL ENTRIES IN lt_data_r WHERE funcname = lt_data_r-funcname.
* SORT lt_tftit BY funcname.
LOOP AT lt_data_t ASSIGNING FIELD-SYMBOL(<fs_data>).
<fs_data>-codetype = lc_t.
<fs_data>-codetext = lc_t_t.
ENDLOOP.
ENDFORM. " GET_TABLE
*&---------------------------------------------------------------------*
*& Form GET_BADI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_badi .
SELECT sa~imp_name AS name
sa~imp_name
aname AS cnam
adate AS cdat
uname AS unam
udate AS udat
utime AS utime
sat~text
t~devclass
INTO CORRESPONDING FIELDS OF TABLE lt_data_b
FROM ( ( ( ( tadir AS t INNER JOIN tdevc AS tc ON t~devclass = tc~devclass )
INNER JOIN sxc_exit AS sx ON sx~exit_name = t~obj_name )
INNER JOIN sxc_attr AS sa ON sx~imp_name = sa~imp_name )
LEFT JOIN sxc_attrt AS sat ON sx~imp_name = sat~imp_name
AND sat~sprsl = sy-langu )
WHERE t~pgmid = lc_r3tr
AND t~object = 'SXSD'
AND sa~active = lc_x
AND ( sa~imp_name LIKE 'Z%' OR sa~imp_name LIKE 'Y%' )
AND sa~imp_name IN s_name
AND aname IN s_cnam.
SELECT * INTO TABLE lt_sxc_attrt FROM sxc_attrt FOR ALL ENTRIES IN lt_data_b WHERE imp_name = lt_data_b-imp_name.
SORT lt_sxc_attrt BY imp_name.
LOOP AT lt_data_b ASSIGNING FIELD-SYMBOL(<fs_data>).
"补充其他语言的描述
IF <fs_data>-text IS INITIAL.
READ TABLE lt_sxc_attrt INTO ls_sxc_attrt WITH KEY imp_name = <fs_data>-imp_name BINARY SEARCH.
IF sy-subrc = 0.
<fs_data>-text = ls_sxc_attrt-text.
ENDIF.
ENDIF.
<fs_data>-codetype = lc_b.
<fs_data>-codetext = lc_b_t.
ENDLOOP.
ENDFORM. " GET_BADI
*&---------------------------------------------------------------------*
*& Form GET_EXIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_exit .
TABLES :modact,modsap,modattr,tadir.
DATA: BEGIN OF t_modsapa OCCURS 0.
INCLUDE STRUCTURE modsapa.
DATA: END OF t_modsapa.
DATA: BEGIN OF t_tfdir OCCURS 0,
funcname LIKE tfdir-funcname,
name LIKE modsapa-name,
devclass LIKE modsapa-devclass,
END OF t_tfdir.
DATA: BEGIN OF ls_tfdir. "note 887475
INCLUDE STRUCTURE tfdir. "note 887475
DATA: stext TYPE tftit-stext, "note 887475
END OF ls_tfdir.
DATA: BEGIN OF t_repo OCCURS 0,
zeile(72) TYPE c,
END OF t_repo.
DATA: xpname LIKE tfdir-pname.
* Read all Exits to selected development classes
SELECT * FROM modsapa INTO TABLE t_modsapa.
READ TABLE t_modsapa INDEX 1.
IF sy-subrc = 0.
* Read the Exits from MODSAP
SELECT * FROM modsap
FOR ALL ENTRIES IN t_modsapa
WHERE name = t_modsapa-name
AND typ = 'E'.
IF NOT modsap-member IS INITIAL.
t_tfdir-funcname = modsap-member.
t_tfdir-name = modsap-name.
READ TABLE t_modsapa WITH KEY name = modsap-name.
IF sy-subrc EQ 0.
t_tfdir-devclass = t_modsapa-devclass.
ENDIF.
APPEND t_tfdir.
ENDIF.
ENDSELECT.
* Read Inlcudes and Function Modules
LOOP AT t_tfdir.
SELECT * INTO CORRESPONDING FIELDS OF ls_tfdir "note 887475
FROM tfdir "note 887475
INNER JOIN tftit ON tftit~funcname = tfdir~funcname "note 887475
WHERE tfdir~funcname = t_tfdir-funcname "note 887475
AND tftit~spras = sy-langu. "note 902606
SHIFT ls_tfdir-pname BY 3 PLACES. "note 887475
xpname = ls_tfdir-pname. "note 887475
REPLACE ' ' WITH 'U' INTO xpname.
REPLACE ' ' WITH ls_tfdir-include INTO xpname. "note 887475
CONDENSE xpname NO-GAPS.
REFRESH t_repo.
READ REPORT xpname INTO t_repo.
DO.
SEARCH t_repo FOR 'INCLUDE'.
IF sy-subrc GT 0.
EXIT.
ENDIF.
READ TABLE t_repo INDEX sy-tabix.
CONDENSE t_repo.
SHIFT t_repo UP TO ' '.
SHIFT t_repo.
REPLACE '.' WITH ' ' INTO t_repo.
DELETE t_repo INDEX sy-tabix.
xpname = t_repo.
* modact, modattr readout and find the Customerproject
SELECT * FROM modact
WHERE member = t_tfdir-name. "SAP Exit Name aus SMOD
EXIT.
ENDSELECT.
IF sy-subrc NE 0.
SELECT * FROM modact
WHERE member = xpname. "Include aus Exit-Baustein
EXIT.
ENDSELECT.
IF sy-subrc NE 0.
SELECT * FROM modact
WHERE member = ls_tfdir-funcname. "note 887475
"SAP Exit Funktionsname
EXIT.
ENDSELECT.
ENDIF.
ENDIF.
CHECK sy-subrc EQ 0.
SELECT SINGLE * FROM modattr
WHERE name = modact-name
AND status = 'A'.
CHECK sy-subrc EQ 0.
SELECT SINGLE * FROM tadir
WHERE obj_name = xpname
AND object = lc_prog
AND pgmid = lc_r3tr.
IF sy-subrc = 0.
ls_data-cust_inc = xpname.
ELSE.
ls_data-cust_inc = space.
ENDIF.
* ls_data-object_type = c_custex.
ls_data-name = t_tfdir-funcname.
ls_data-devclass = t_tfdir-devclass.
ls_data-mod = t_tfdir-name.
ls_data-pname = modattr-name.
ls_data-cnam = modattr-anam.
ls_data-cdat = modattr-adat.
ls_data-text = ls_tfdir-stext.
ls_data-codetype = lc_e.
ls_data-codetext = lc_e_t.
APPEND ls_data TO lt_data_e.
ENDDO.
ENDSELECT.
ENDLOOP.
ENDIF.
DELETE lt_data_e WHERE name NOT IN s_name OR cnam NOT IN s_cnam.
ENDFORM. " GET_EXIT
*&---------------------------------------------------------------------*
*& Form GET_ODATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_odata .
DATA:lv_timestamp TYPE tzonref-tstamps.
"获取ODATA表
SELECT a~project AS name
creation_user_id AS cnam
last_chg_user_id AS unam
description AS text
creation_time
last_chg_time
devclass
INTO CORRESPONDING FIELDS OF TABLE lt_data_o
FROM /iwbep/i_sbd_pr AS a LEFT JOIN /iwbep/i_sbd_prt AS b ON a~project = b~project
AND sylangu = sy-langu
JOIN tadir ON a~project = tadir~obj_name
AND object = lc_iwpr
AND pgmid = lc_r3tr
WHERE ( a~project LIKE 'Z%' OR a~project LIKE 'Y%' )
AND a~project IN s_name
AND creation_user_id IN s_cnam
.
*
* SELECT * INTO TABLE lt_tftit FROM tftit FOR ALL ENTRIES IN lt_data_r WHERE funcname = lt_data_r-funcname.
* SORT lt_tftit BY funcname.
LOOP AT lt_data_o ASSIGNING FIELD-SYMBOL(<fs_data>).
lv_timestamp = <fs_data>-creation_time.
CALL FUNCTION 'CIF_GEN4_CONVERT_TIMESTAMP'
EXPORTING
iv_timestamp = lv_timestamp
iv_timezone = sy-zonlo
IMPORTING
ev_date = <fs_data>-cdat
ev_time = <fs_data>-ctime
EXCEPTIONS
time_conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
CLEAR :<fs_data>-cdat, <fs_data>-ctime.
ENDIF.
lv_timestamp = <fs_data>-last_chg_time.
CALL FUNCTION 'CIF_GEN4_CONVERT_TIMESTAMP'
EXPORTING
iv_timestamp = lv_timestamp
iv_timezone = sy-zonlo
IMPORTING
ev_date = <fs_data>-udat
ev_time = <fs_data>-utime
EXCEPTIONS
time_conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
CLEAR :<fs_data>-udat, <fs_data>-utime.
ENDIF.
<fs_data>-codetype = lc_o.
<fs_data>-codetext = lc_o_t.
ENDLOOP.
ENDFORM. " GET_ODATA
*&---------------------------------------------------------------------*
*& Form get_rfc_text
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& <-- LS_DATA_NAME
*& --> LT_TEXT[]
*&---------------------------------------------------------------------*
FORM get_rfc_text TABLES pt_text LIKE lt_text[]
CHANGING pv_name .
DATA:lv_index TYPE p VALUE 1.
DATA:lv_text TYPE char100.
PERFORM append_text TABLES pt_text USING '接口名' pv_name CHANGING lv_index .
PERFORM append_text TABLES pt_text USING '接口程序名' ls_data-pname CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '程序描述' ls_data-text CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建者' ls_data-cnam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建日期' ls_data-cdat CHANGING lv_index.
IF ls_data-unam IS NOT INITIAL.
PERFORM append_text TABLES pt_text USING '修改者' ls_data-unam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改日期' ls_data-udat CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改时间' ls_data-utime CHANGING lv_index.
ENDIF.
*
CLEAR sofunctionname[].
sofunctionname = VALUE #( sign = 'I'
option = 'EQ'
low = pv_name
).
APPEND sofunctionname.
PERFORM retrievefunctions USING sofunctionname[] "Function name
sofunctiongroup[] "Function group
ifunctions[] "Found functions
soauthor[] "Author
'X' "Get text elements
'X' "Get screens
'X' "Customer data only
'^'. "Customer name range
LOOP AT ifunctions.
* Find Dict structures, messages, functions, includes etc.
PERFORM scanforadditionalfuncstuff USING ifunctions[]
'X' "Search for includes recursively
'X' "Search for functions recursively
' ' "Search for includes
'X' "Search for functions
' ' "search for dictionary objects
' ' "Search for messages
'X' "Customer data only
'^'. "Customer name range
ENDLOOP.
DELETE ifunctions WHERE functionname = pv_name.
IF ifunctions[] IS NOT INITIAL.
lv_text = |{ pv_name }下自定义函数|.
PERFORM append_text TABLES pt_text USING lv_text '' CHANGING lv_index.
LOOP AT ifunctions.
PERFORM append_text TABLES pt_text USING ifunctions-functionname ifunctions-functiontitle CHANGING lv_index.
ENDLOOP.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_badi_text
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> LT_TEXT[]
*& <-- LS_DATA_NAME
*&---------------------------------------------------------------------*
FORM get_badi_text TABLES pt_text LIKE lt_text[]
CHANGING pv_name .
DATA:lv_index TYPE p VALUE 1.
PERFORM append_text TABLES pt_text USING '接口名' pv_name CHANGING lv_index .
PERFORM append_text TABLES pt_text USING '程序描述' ls_data-text CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建者' ls_data-cnam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建日期' ls_data-cdat CHANGING lv_index.
IF ls_data-unam IS NOT INITIAL.
PERFORM append_text TABLES pt_text USING '修改者' ls_data-unam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改日期' ls_data-udat CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改时间' ls_data-utime CHANGING lv_index.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_program_text
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> LT_TEXT[]
*& <-- LS_DATA_NAME
*&---------------------------------------------------------------------*
FORM get_program_text TABLES pt_text LIKE lt_text[]
CHANGING pv_name .
DATA:lv_index TYPE p VALUE 1.
DATA:lv_text TYPE char100.
PERFORM append_text TABLES pt_text USING '程序名' pv_name CHANGING lv_index .
PERFORM append_text TABLES pt_text USING '程序描述' ls_data-text CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建者' ls_data-cnam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建日期' ls_data-cdat CHANGING lv_index.
IF ls_data-unam IS NOT INITIAL.
PERFORM append_text TABLES pt_text USING '修改者' ls_data-unam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改日期' ls_data-udat CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改时间' ls_data-utime CHANGING lv_index.
ENDIF.
CLEAR soprogramname[].
soprogramname = VALUE #( sign = 'I'
option = 'EQ'
low = pv_name
).
APPEND soprogramname.
PERFORM retrieveprograms USING iprograms[]
ifunctions[]
soprogramname[] "Program name
soauthor[] "Author
'^' "Customer name range
'X' "Also modified by author
'X' "Customer object only
'X' "Find messages
'X' "Text Elements
'X' "Dictionay structures
'X' "Get functions
'X' "Get includes
'X' "Get screens
'X' "Search recursively for functions
'X' "Search recursively for includes
'' "local objects
ls_data-devclass. "Package
DELETE ifunctions WHERE functionname = pv_name.
IF ifunctions[] IS NOT INITIAL.
lv_text = |{ pv_name }下自定义函数|.
PERFORM append_text TABLES pt_text USING lv_text '' CHANGING lv_index.
LOOP AT ifunctions.
PERFORM append_text TABLES pt_text USING ifunctions-functionname ifunctions-functiontitle CHANGING lv_index.
ENDLOOP.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_class_text
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> LT_TEXT[]
*& <-- LS_DATA_NAME
*&---------------------------------------------------------------------*
FORM get_class_text TABLES pt_text LIKE lt_text[]
CHANGING pv_name .
DATA:lv_index TYPE p VALUE 1.
PERFORM append_text TABLES pt_text USING 'CLASS名' pv_name CHANGING lv_index .
PERFORM append_text TABLES pt_text USING '程序描述' ls_data-text CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建者' ls_data-cnam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建日期' ls_data-cdat CHANGING lv_index.
IF ls_data-unam IS NOT INITIAL.
PERFORM append_text TABLES pt_text USING '修改者' ls_data-unam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改日期' ls_data-udat CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改时间' ls_data-utime CHANGING lv_index.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_table_text
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> LT_TEXT[]
*& <-- LS_DATA_NAME
*&---------------------------------------------------------------------*
FORM get_table_text TABLES pt_text LIKE lt_text[]
CHANGING pv_name .
DATA:lv_index TYPE p VALUE 1.
DATA:lv_text TYPE char100.
DATA:lw_name TYPE ddobjname.
DATA: ps_02v TYPE dd02v,
ps_09V TYPE dd09v.
DATA: it_flds TYPE TABLE OF dd03p WITH HEADER LINE .
PERFORM append_text TABLES pt_text USING '表名' pv_name CHANGING lv_index .
PERFORM append_text TABLES pt_text USING '描述' ls_data-text CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建者' ls_data-cnam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建日期' ls_data-cdat CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '表类型' ls_data-tabclass CHANGING lv_index.
IF ls_data-unam IS NOT INITIAL.
PERFORM append_text TABLES pt_text USING '修改者' ls_data-unam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改日期' ls_data-udat CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改时间' ls_data-utime CHANGING lv_index.
ENDIF.
lv_text = |{ pv_name }字段|.
PERFORM append_text TABLES pt_text USING lv_text '' CHANGING lv_index.
lw_name = pv_name.
CALL FUNCTION 'DDIF_TABL_GET'
EXPORTING
name = lw_name
state = 'A'
langu = sy-langu
IMPORTING
* GOTSTATE =
dd02v_wa = ps_02v
dd09l_wa = ps_09V
TABLES
dd03p_tab = it_flds
* DD05M_TAB =
* DD08V_TAB =
* DD12V_TAB =
* DD17V_TAB =
* DD35V_TAB =
* DD36M_TAB =
EXCEPTIONS
illegal_input = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
LOOP AT it_flds.
PERFORM append_text TABLES pt_text USING it_flds-FIELDNAME it_flds-DDTEXT CHANGING lv_index.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_exit_text
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> LT_TEXT[]
*& <-- LS_DATA_NAME
*&---------------------------------------------------------------------*
FORM get_exit_text TABLES pt_text LIKE lt_text[]
CHANGING pv_name .
DATA:lv_index TYPE p VALUE 1.
PERFORM append_text TABLES pt_text USING '接口名' pv_name CHANGING lv_index .
PERFORM append_text TABLES pt_text USING '程序描述' ls_data-text CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建者' ls_data-cnam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建日期' ls_data-cdat CHANGING lv_index.
IF ls_data-unam IS NOT INITIAL.
PERFORM append_text TABLES pt_text USING '修改者' ls_data-unam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改日期' ls_data-udat CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改时间' ls_data-utime CHANGING lv_index.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_odata_text
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> LT_TEXT[]
*& <-- LS_DATA_NAME
*&---------------------------------------------------------------------*
FORM get_odata_text TABLES pt_text LIKE lt_text[]
CHANGING pv_name .
DATA:lv_index TYPE p VALUE 1.
PERFORM append_text TABLES pt_text USING '接口名' pv_name CHANGING lv_index .
PERFORM append_text TABLES pt_text USING '程序描述' ls_data-text CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建者' ls_data-cnam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '创建日期' ls_data-cdat CHANGING lv_index.
IF ls_data-unam IS NOT INITIAL.
PERFORM append_text TABLES pt_text USING '修改者' ls_data-unam CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改日期' ls_data-udat CHANGING lv_index.
PERFORM append_text TABLES pt_text USING '最后一次修改时间' ls_data-utime CHANGING lv_index.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form append_text
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> PT_TEXT
*& --> LV_TEXT
*& --> PS_DATA_NAME
*& <-- LV_INDEX
*&---------------------------------------------------------------------*
FORM append_text TABLES pt_text LIKE lt_text
USING p_text
p_describe
CHANGING p_index.
ls_text = VALUE #( zindex = p_index
ztext = p_text
zdescribe = p_describe
).
APPEND ls_text TO pt_text[].
p_index = p_index + 1.
CLEAR:ls_text.
ENDFORM.
*----------------------------------------------------------------------------------------------------------------------
* retrieveFunctions... Retrieve function modules from SAP DB. May be called in one of two ways
*----------------------------------------------------------------------------------------------------------------------
FORM retrievefunctions USING sofname LIKE sofunctionname[]
sofgroup LIKE sofunctiongroup[]
ilocfunctionnames LIKE ifunctions[]
VALUE(solocauthor) LIKE soauthor[]
VALUE(gettextelements)
VALUE(getscreens)
VALUE(customeronly)
VALUE(customernamerange).
RANGES: rangefuncname FOR tfdir-funcname.
RANGES: rangefuncgroup FOR enlfdir-area.
DATA: wafunctionname TYPE tfunction.
DATA: nogroupsfound TYPE i VALUE true.
DATA: previousfg TYPE v_fdir-area.
rangefuncname[] = sofname[].
rangefuncgroup[] = sofgroup[].
IF NOT solocauthor[] IS INITIAL.
*-- Need to select all function groups by author
SELECT area
FROM tlibv
INTO rangefuncgroup-low
WHERE uname IN solocauthor
AND area IN sofgroup[].
rangefuncgroup-sign = 'I'.
rangefuncgroup-option = 'EQ'.
APPEND rangefuncgroup.
nogroupsfound = false.
ENDSELECT.
ELSE.
nogroupsfound = false.
ENDIF.
IF nogroupsfound = false.
* select by function name and/or function group.
SELECT funcname area
FROM v_fdir
INTO (wafunctionname-functionname,
wafunctionname-functiongroup)
WHERE funcname IN rangefuncname
AND area IN rangefuncgroup
AND generated = ''
ORDER BY area.
APPEND wafunctionname TO ilocfunctionnames.
ENDSELECT.
ENDIF.
LOOP AT ilocfunctionnames INTO wafunctionname.
PERFORM retrievefunctiondetail USING wafunctionname-functionname
wafunctionname-progname
wafunctionname-includenumber
wafunctionname-functiontitle.
PERFORM findmainfunctioninclude USING wafunctionname-progname
wafunctionname-includenumber
wafunctionname-functionmaininclude.
PERFORM findfunctiontopinclude USING wafunctionname-progname
wafunctionname-topincludename.
* Find all user defined includes within the function group
PERFORM scanforfunctionincludes USING wafunctionname-progname
customeronly
customernamerange
wafunctionname-iincludes[].
* Find main message class
PERFORM findmainmessageclass USING wafunctionname-progname
wafunctionname-messageclass.
* Find any screens declared within the main include
IF NOT getscreens IS INITIAL.
IF previousfg IS INITIAL OR previousfg <> wafunctionname-functiongroup.
PERFORM findfunctionscreenflow USING wafunctionname.
* Search for any GUI texts
PERFORM retrieveguititles USING wafunctionname-iguititle[]
wafunctionname-progname.
ENDIF.
ENDIF.
IF NOT gettextelements IS INITIAL.
* Find the program texts from out of the database.
PERFORM retrieveprogramtexts USING wafunctionname-iselectiontexts[]
wafunctionname-itextelements[]
wafunctionname-progname.
ENDIF.
previousfg = wafunctionname-functiongroup.
MODIFY ilocfunctionnames FROM wafunctionname.
ENDLOOP.
ENDFORM. "retrieveFunctions
FORM scanforfunctions USING VALUE(programname)
VALUE(programlinkname)
VALUE(recursiveincludes)
VALUE(recursivefunctions)
VALUE(customeronly)
VALUE(customernamerange)
ilocfunctions LIKE ifunctions[].
DATA: iincludelines TYPE STANDARD TABLE OF string WITH HEADER LINE.
DATA: itokens TYPE STANDARD TABLE OF stokes WITH HEADER LINE.
DATA: istatements TYPE STANDARD TABLE OF sstmnt WITH HEADER LINE.
DATA: watokens TYPE stokes.
DATA: wafunction TYPE tfunction.
DATA: wafunctioncomparison TYPE tfunction.
DATA: maxlines TYPE i.
DATA: nextline TYPE i.
DATA: castprogramname TYPE program.
DATA: skipthisloop TYPE i.
* Read the program code from the textpool.
castprogramname = programname.
READ REPORT castprogramname INTO iincludelines.
SCAN ABAP-SOURCE iincludelines TOKENS INTO itokens WITH INCLUDES STATEMENTS INTO istatements.
CLEAR iincludelines[].
maxlines = lines( itokens ).
LOOP AT itokens WHERE str = function AND type = 'I'.
nextline = sy-tabix + 1.
IF nextline <= maxlines.
READ TABLE itokens INDEX nextline INTO watokens.
* Are we only to find customer functions
skipthisloop = false.
IF NOT customeronly IS INITIAL.
TRY.
IF watokens-str+1(1) = 'Y' OR watokens-str+1(1) = 'Z' OR watokens-str CS customernamerange.
ELSE.
skipthisloop = true.
ENDIF.
CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
CLEANUP.
skipthisloop = true.
ENDTRY.
ENDIF.
IF skipthisloop = false.
wafunction-functionname = watokens-str.
REPLACE ALL OCCURRENCES OF '''' IN wafunction-functionname WITH ' '.
CONDENSE wafunction-functionname.
* Don't add a function if we alread have it listed.
READ TABLE ilocfunctions WITH KEY functionname = wafunction-functionname INTO wafunctioncomparison.
IF sy-subrc <> 0.
* Add in the link name if the function is linked to a program
wafunction-programlinkname = programlinkname.
* Don't download functions which are called through an RFC destination
nextline = sy-tabix + 2.
READ TABLE itokens INDEX nextline INTO watokens.
IF watokens-str <> destination.
* Find the function group
SELECT SINGLE area FROM v_fdir INTO wafunction-functiongroup WHERE funcname = wafunction-functionname.
IF sy-subrc = 0.
* Best find the function number as well.
PERFORM retrievefunctiondetail USING wafunction-functionname
wafunction-progname
wafunction-includenumber
wafunction-functiontitle.
PERFORM findmainfunctioninclude USING wafunction-progname
wafunction-includenumber
wafunction-functionmaininclude.
PERFORM findfunctiontopinclude USING wafunction-progname
wafunction-topincludename.
* Find main message class
PERFORM findmainmessageclass USING wafunction-progname
wafunction-messageclass.
APPEND wafunction TO ilocfunctions.
* Now lets search a little bit deeper and do a recursive search for other includes
IF NOT recursiveincludes IS INITIAL.
PERFORM scanforincludeprograms USING wafunction-functionmaininclude
recursiveincludes
customeronly
customernamerange
wafunction-iincludes[].
ENDIF.
* Now lets search a little bit deeper and do a recursive search for other functions
IF NOT recursivefunctions IS INITIAL.
PERFORM scanforfunctions USING wafunction-functionmaininclude
space
recursiveincludes
recursivefunctions
customeronly
customernamerange
ilocfunctions[].
ENDIF.
CLEAR wafunction.
ENDIF.
ENDIF.
ENDIF.
CLEAR wafunction.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------------------------------------------------------
* retrieveFunctionDetail... Retrieve function module details from SAP DB.
*----------------------------------------------------------------------------------------------------------------------
FORM retrievefunctiondetail USING VALUE(functionname)
progname
includename
titletext.
SELECT SINGLE pname
include
FROM tfdir
INTO (progname, includename)
WHERE funcname = functionname.
IF sy-subrc = 0.
SELECT SINGLE stext
FROM tftit
INTO titletext
WHERE spras = sy-langu
AND funcname = functionname.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------------------------------------------------------
* findMainFunctionInclude... Find the main include that contains the source code
*----------------------------------------------------------------------------------------------------------------------
FORM findmainfunctioninclude USING VALUE(programname)
VALUE(includeno)
internalincludename.
DATA: newincludenumber TYPE string.
CONCATENATE '%U' includeno INTO newincludenumber.
SELECT SINGLE include
FROM d010inc
INTO internalincludename
WHERE master = programname
AND include LIKE newincludenumber.
ENDFORM.
*----------------------------------------------------------------------------------------------------------------------
* findFunctionTopInclude... Find the top include for the function group
*----------------------------------------------------------------------------------------------------------------------
FORM findfunctiontopinclude USING VALUE(programname)
topincludename.
SELECT SINGLE include
FROM d010inc
INTO topincludename
WHERE master = programname
AND include LIKE '%TOP'.
ENDFORM.
*-------------------------------------------------------------------------------------------------------
* findMainMessageClass... find the message class stated at the top of program.
*-------------------------------------------------------------------------------------------------------
FORM findmainmessageclass USING VALUE(programname)
messageclass.
SELECT SINGLE msgid
FROM trdire INTO messageclass
WHERE report = programname.
ENDFORM.
*----------------------------------------------------------------------------------------------------------------------
* scanForIncludePrograms... Search each program for include programs
*----------------------------------------------------------------------------------------------------------------------
FORM scanforincludeprograms USING VALUE(programname)
VALUE(recursiveincludes)
VALUE(customeronly)
VALUE(customernamerange)
ilocincludes LIKE dumiincludes[].
DATA: iincludelines TYPE STANDARD TABLE OF string WITH HEADER LINE.
DATA: itokens TYPE STANDARD TABLE OF stokes WITH HEADER LINE.
DATA: ikeywords TYPE STANDARD TABLE OF text20 WITH HEADER LINE.
DATA: istatements TYPE STANDARD TABLE OF sstmnt WITH HEADER LINE.
DATA: watokens TYPE stokes.
DATA: wainclude TYPE tinclude.
DATA: waincludeexists TYPE tinclude.
DATA: maxlines TYPE i.
DATA: nextline TYPE i.
DATA: castprogramname TYPE program.
* Read the program code from the textpool.
castprogramname = programname.
READ REPORT castprogramname INTO iincludelines.
APPEND include TO ikeywords.
SCAN ABAP-SOURCE iincludelines TOKENS INTO itokens WITH INCLUDES STATEMENTS INTO istatements KEYWORDS FROM ikeywords.
CLEAR iincludelines[].
maxlines = lines( itokens ).
LOOP AT itokens WHERE str = include AND type = 'I'.
nextline = sy-tabix + 1.
IF nextline <= maxlines.
READ TABLE itokens INDEX nextline INTO watokens.
* Are we only to find customer includes?
IF NOT customeronly IS INITIAL.
TRY.
IF watokens-str+0(1) = 'Y' OR watokens-str+0(1) = 'Z' OR watokens-str CS customernamerange
OR watokens-str+0(2) = 'MZ' OR watokens-str+0(2) = 'MY'.
ELSE.
CONTINUE.
ENDIF.
CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
ENDTRY.
ENDIF.
wainclude-includename = watokens-str.
* Best find the program title text as well.
PERFORM findprogramorincludetitle USING wainclude-includename
wainclude-includetitle.
* Don't append the include if we already have it listed
READ TABLE ilocincludes INTO waincludeexists WITH KEY includename = wainclude-includename.
IF sy-subrc <> 0.
APPEND wainclude TO ilocincludes.
IF NOT recursiveincludes IS INITIAL.
* Do a recursive search for other includes
PERFORM scanforincludeprograms USING wainclude-includename
recursiveincludes
customeronly
customernamerange
ilocincludes[].
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
*----------------------------------------------------------------------------------------------------------------------
* findProgramOrIncludeTitle... Finds the title text of a program.
*----------------------------------------------------------------------------------------------------------------------
FORM findprogramorincludetitle USING VALUE(programname)
titletext.
SELECT SINGLE text
FROM trdirt
INTO titletext
WHERE name = programname
AND sprsl = sy-langu.
ENDFORM. "findMainMessageClass
*-------------------------------------------------------------------------------------------------------
* findFunctionScreenFlow...
*-------------------------------------------------------------------------------------------------------
FORM findfunctionscreenflow USING wafunction TYPE tfunction.
DATA: iflow TYPE STANDARD TABLE OF tscreenflow WITH HEADER LINE.
CALL FUNCTION 'DYNPRO_PROCESSINGLOGIC'
EXPORTING
rep_name = wafunction-progname
TABLES
scr_logic = iflow.
SORT iflow ASCENDING BY screen.
DELETE ADJACENT DUPLICATES FROM iflow COMPARING screen.
LOOP AT iflow.
APPEND iflow TO wafunction-iscreenflow.
ENDLOOP.
ENDFORM. "findFunctionScreenFlow
*-------------------------------------------------------------------------------------------------------
* retrieveGUITitles... Search for any GUI texts
*-------------------------------------------------------------------------------------------------------
FORM retrieveguititles USING ilocguititle LIKE dumiguititle[]
VALUE(programname).
SELECT obj_code
text
FROM d347t
APPENDING CORRESPONDING FIELDS OF TABLE ilocguititle
WHERE progname = programname.
ENDFORM.
*-------------------------------------------------------------------------------------------------------
* retrieveProgramTexts... Find the text elements and selection texts for a program
*-------------------------------------------------------------------------------------------------------
FORM retrieveprogramtexts USING ilocselectiontexts LIKE dumitexttab[]
iloctextelements LIKE dumitexttab[]
VALUE(programname).
DATA: itexttable TYPE STANDARD TABLE OF ttexttable WITH HEADER LINE.
DATA: watexts TYPE ttexttable.
DATA: castprogramname(50).
MOVE programname TO castprogramname.
READ TEXTPOOL castprogramname INTO itexttable LANGUAGE sy-langu.
DELETE itexttable WHERE key = 'R'.
* Selection texts.
LOOP AT itexttable WHERE id = 'S'.
MOVE itexttable-key TO watexts-key.
MOVE itexttable-entry TO watexts-entry.
APPEND watexts TO ilocselectiontexts.
CLEAR watexts.
ENDLOOP.
* Text elements.
DELETE itexttable WHERE key = 'S'.
LOOP AT itexttable WHERE id = 'I'.
MOVE itexttable-key TO watexts-key.
MOVE itexttable-entry TO watexts-entry.
APPEND watexts TO iloctextelements.
ENDLOOP.
ENDFORM. "retrieveProgramTexts
*----------------------------------------------------------------------------------------------------------------------
* scanForFunctionIncludes... Find all user defined includes within the function group
*----------------------------------------------------------------------------------------------------------------------
FORM scanforfunctionincludes USING poolname
VALUE(customeronly)
VALUE(customernamerange)
ilocincludes LIKE dumiincludes[].
DATA: iincludelines TYPE STANDARD TABLE OF string WITH HEADER LINE.
DATA: itokens TYPE STANDARD TABLE OF stokes WITH HEADER LINE.
DATA: ikeywords TYPE STANDARD TABLE OF text20 WITH HEADER LINE.
DATA: istatements TYPE STANDARD TABLE OF sstmnt WITH HEADER LINE.
DATA: watokens TYPE stokes.
DATA: wainclude TYPE tinclude.
DATA: waincludeexists TYPE tinclude.
DATA: maxlines TYPE i.
DATA: nextline TYPE i.
DATA: castprogramname TYPE program.
* Read the program code from the textpool.
castprogramname = poolname.
READ REPORT castprogramname INTO iincludelines.
APPEND include TO ikeywords.
SCAN ABAP-SOURCE iincludelines TOKENS INTO itokens WITH INCLUDES STATEMENTS INTO istatements KEYWORDS FROM ikeywords.
CLEAR iincludelines[].
maxlines = lines( itokens ).
LOOP AT itokens WHERE str = include AND type = 'I'.
nextline = sy-tabix + 1.
IF nextline <= maxlines.
READ TABLE itokens INDEX nextline INTO watokens.
IF watokens-str CP '*F++'.
* Are we only to find customer includes?
IF NOT customeronly IS INITIAL.
TRY.
IF watokens-str+0(2) = 'LY' OR watokens-str+0(2) = 'LZ' OR watokens-str CS customernamerange.
ELSE.
CONTINUE.
ENDIF.
CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
ENDTRY.
ENDIF.
wainclude-includename = watokens-str.
* Best find the program title text as well.
PERFORM findprogramorincludetitle USING wainclude-includename
wainclude-includetitle.
* Don't append the include if we already have it listed
READ TABLE ilocincludes INTO waincludeexists WITH KEY includename = wainclude-includename.
IF sy-subrc <> 0.
APPEND wainclude TO ilocincludes.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. "scanForFunctionIncludes
*----------------------------------------------------------------------------------------------------------------------
* scanForAdditionalFuncStuff... Search for additional things relating to functions
*----------------------------------------------------------------------------------------------------------------------
FORM scanforadditionalfuncstuff USING ilocfunctions LIKE ifunctions[]
VALUE(recursiveincludes)
VALUE(recursivefunctions)
VALUE(searchforincludes)
VALUE(searchforfunctions)
VALUE(searchfordictionary)
VALUE(searchformessages)
VALUE(customeronly)
VALUE(customernamerange).
DATA: wafunction TYPE tfunction.
DATA: wainclude TYPE tinclude.
LOOP AT ilocfunctions INTO wafunction.
IF NOT searchforincludes IS INITIAL.
* Search in the main include
PERFORM scanforincludeprograms USING wafunction-functionmaininclude
recursiveincludes
customeronly
customernamerange
wafunction-iincludes[].
* Search in the top include
PERFORM scanforincludeprograms USING wafunction-topincludename
recursiveincludes
customeronly
customernamerange
wafunction-iincludes[].
ENDIF.
IF NOT searchforfunctions IS INITIAL.
PERFORM scanforfunctions USING wafunction-functionmaininclude
wafunction-programlinkname
recursiveincludes
recursivefunctions
customeronly
customernamerange
ilocfunctions[].
ENDIF.
MODIFY ilocfunctions FROM wafunction.
ENDLOOP.
* Now we have everthing perhaps we had better find all the dictionary structures
IF NOT searchfordictionary IS INITIAL.
LOOP AT ilocfunctions INTO wafunction.
PERFORM scanfortables USING wafunction-progname
customeronly
customernamerange
wafunction-idictstruct[].
PERFORM scanforlikeortype USING wafunction-progname
customeronly
customernamerange
wafunction-idictstruct[].
LOOP AT wafunction-iincludes INTO wainclude.
PERFORM scanfortables USING wainclude-includename
customeronly
customernamerange
wafunction-idictstruct[].
PERFORM scanforlikeortype USING wainclude-includename
customeronly
customernamerange
wafunction-idictstruct[].
ENDLOOP.
MODIFY ilocfunctions FROM wafunction.
ENDLOOP.
ENDIF.
* Now search for all messages
IF NOT searchformessages IS INITIAL.
LOOP AT ilocfunctions INTO wafunction.
PERFORM scanformessages USING wafunction-progname
wafunction-messageclass
wafunction-imessages[].
MODIFY ilocfunctions FROM wafunction.
ENDLOOP.
ENDIF.
ENDFORM. "scanForAdditionalFuncStuff
*-------------------------------------------------------------------------------------------------------
* scanForLikeOrType... Look for any dictionary objects referenced by a like or type statement
*-------------------------------------------------------------------------------------------------------
FORM scanforlikeortype USING VALUE(programname)
VALUE(customeronly)
VALUE(customernamerange)
ilocdictionary LIKE idictionary[].
DATA ilines TYPE STANDARD TABLE OF string WITH HEADER LINE.
DATA: head TYPE string.
DATA: tail TYPE string.
DATA: junk TYPE string.
DATA: linetype TYPE string.
DATA: linelength TYPE i VALUE 0.
DATA: endofline TYPE i VALUE true.
DATA: wadictionary TYPE tdicttable.
DATA: wadictionarycomparison TYPE tdicttable.
DATA: waline TYPE string.
DATA: castprogramname TYPE program.
* Read the program code from the textpool.
castprogramname = programname.
READ REPORT castprogramname INTO ilines.
LOOP AT ilines INTO waline.
* Find custom tables.
linelength = strlen( waline ).
IF linelength > 0.
IF waline(1) = asterix.
CONTINUE.
ENDIF.
TRANSLATE waline TO UPPER CASE.
* Determine the lineType.
IF endofline = true.
SHIFT waline UP TO like.
IF sy-subrc = 0.
linetype = like.
ELSE.
SHIFT waline UP TO type.
IF sy-subrc = 0.
FIND 'BEGIN OF' IN waline.
IF sy-subrc <> 0.
FIND 'END OF' IN waline.
IF sy-subrc <> 0.
FIND 'VALUE' IN waline.
IF sy-subrc <> 0.
linetype = type.
ENDIF.
ENDIF.
ENDIF.
ELSE.
SHIFT waline UP TO include.
IF sy-subrc = 0.
SPLIT waline AT space INTO junk ilines.
ENDIF.
SHIFT waline UP TO structure.
IF sy-subrc = 0.
linetype = structure.
ELSE.
CONTINUE.
ENDIF.
ENDIF.
ENDIF.
ELSE.
linetype = comma.
ENDIF.
CASE linetype.
WHEN like OR type OR structure.
* Work on the appropriate lineType
SHIFT waline UP TO space.
SHIFT waline LEFT DELETING LEADING space.
IF waline CS table.
SPLIT waline AT table INTO head tail.
SPLIT tail AT 'OF' INTO head tail.
waline = tail.
SHIFT waline LEFT DELETING LEADING space.
ENDIF.
* Are we only to download SAP dictionary structures.
IF NOT customeronly IS INITIAL.
TRY.
IF waline+0(1) = 'Y' OR waline+0(1) = 'Z' OR waline CS customernamerange.
ELSE.
linetype = ''.
CONTINUE.
ENDIF.
CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
ENDTRY.
ENDIF.
IF waline CS comma.
SPLIT waline AT comma INTO head tail.
IF waline CS dash.
SPLIT head AT dash INTO head tail.
ENDIF.
IF waline CS occurs.
SPLIT waline AT space INTO head tail.
ENDIF.
ELSE.
IF waline CS period.
SPLIT waline AT period INTO head tail.
IF waline CS dash.
SPLIT head AT dash INTO head tail.
ENDIF.
IF waline CS occurs.
SPLIT waline AT space INTO head tail.
ENDIF.
ELSE.
SPLIT waline AT space INTO head tail.
IF waline CS dash.
SPLIT head AT dash INTO head tail.
ENDIF.
ENDIF.
ENDIF.
IF NOT head IS INITIAL.
wadictionary-tablename = head.
* Don't append the object if we already have it listed
READ TABLE ilocdictionary INTO wadictionarycomparison
WITH KEY tablename = wadictionary-tablename.
IF sy-subrc <> 0.
PERFORM findtabledescription USING wadictionary-tablename
wadictionary-tabletitle.
PERFORM findtabledefinition USING wadictionary-tablename
wadictionary-istructure[].
* Only append if the item is a table and not a structure or data element
IF NOT wadictionary-istructure[] IS INITIAL.
APPEND wadictionary TO ilocdictionary.
ENDIF.
ENDIF.
CLEAR wadictionary.
ENDIF.
linetype = ''.
ENDCASE.
ENDIF.
ENDLOOP.
ENDFORM. "scanForLikeOrType
*----------------------------------------------------------------------------------------------------------------------
* findTableDefinition... Find the structure of a table from the SAP database.
*----------------------------------------------------------------------------------------------------------------------
FORM findtabledefinition USING VALUE(tablename)
idictstruct LIKE dumidictstructure[].
DATA gotstate LIKE dcobjif-gotstate.
DATA: definition TYPE STANDARD TABLE OF dd03p WITH HEADER LINE.
DATA: wadictstruct TYPE tdicttablestructure.
CALL FUNCTION 'DDIF_TABL_GET'
EXPORTING
name = tablename
state = 'A'
langu = sy-langu
IMPORTING
gotstate = gotstate
TABLES
dd03p_tab = definition
EXCEPTIONS
illegal_input = 1
OTHERS = 2.
IF sy-subrc = 0 AND gotstate = 'A'.
LOOP AT definition.
MOVE-CORRESPONDING definition TO wadictstruct.
PERFORM removeleadingzeros CHANGING wadictstruct-position.
PERFORM removeleadingzeros CHANGING wadictstruct-leng.
APPEND wadictstruct TO idictstruct.
ENDLOOP.
ENDIF.
ENDFORM. "findTableDefinition
*----------------------------------------------------------------------------------------------------------------------
* findTableDescription... Search for table description in dictionary
*----------------------------------------------------------------------------------------------------------------------
FORM findtabledescription USING VALUE(tablename)
tabledescription.
SELECT SINGLE ddtext
FROM dd02t
INTO tabledescription
WHERE tabname = tablename
AND ddlanguage = sy-langu.
ENDFORM. "findTableDescription
*-------------------------------------------------------------------------------------------------------
* removeLeadingZeros...
*-------------------------------------------------------------------------------------------------------
FORM removeleadingzeros CHANGING myvalue.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = myvalue
IMPORTING
output = myvalue
EXCEPTIONS
OTHERS = 1.
ENDFORM. "removeLeadingZeros
*-------------------------------------------------------------------------------------------------------
* scanForMessages... Search each program for messages
*-------------------------------------------------------------------------------------------------------
FORM scanformessages USING VALUE(programname)
VALUE(mainmessageclass)
ilocmessages LIKE imessages[].
DATA: iincludelines TYPE STANDARD TABLE OF string WITH HEADER LINE.
DATA: itokens TYPE STANDARD TABLE OF stokes WITH HEADER LINE.
DATA: istatements TYPE STANDARD TABLE OF sstmnt WITH HEADER LINE.
DATA: ikeywords TYPE STANDARD TABLE OF text20 WITH HEADER LINE.
DATA: wamessage TYPE tmessage.
DATA: wamessagecomparison TYPE tmessage.
DATA: watokens TYPE stokes.
DATA: nextline TYPE i.
DATA: stringlength TYPE i VALUE 0.
DATA: workingonmessage TYPE i VALUE false.
DATA: castprogramname TYPE program.
* Read the program code from the textpool.
castprogramname = programname.
READ REPORT castprogramname INTO iincludelines.
APPEND message TO ikeywords.
SCAN ABAP-SOURCE iincludelines TOKENS INTO itokens WITH INCLUDES STATEMENTS INTO istatements KEYWORDS FROM ikeywords.
CLEAR iincludelines[].
LOOP AT itokens.
IF itokens-str = message.
workingonmessage = true.
CONTINUE.
ENDIF.
IF workingonmessage = true.
stringlength = strlen( itokens-str ).
* Message declaration 1
IF stringlength = 4 AND itokens-str+0(1) CA sy-abcde.
wamessage-msgnr = itokens-str+1(3).
wamessage-arbgb = mainmessageclass.
ELSE.
IF itokens-str CS '''' OR itokens-str CS '`'.
* Message declaration 2
TRANSLATE itokens-str USING ''' '.
TRANSLATE itokens-str USING '` '.
CONDENSE itokens-str.
SHIFT itokens-str LEFT DELETING LEADING space.
wamessage-text = itokens-str.
wamessage-arbgb = 'Hard coded'.
ELSE.
IF itokens-str = 'ID'.
* Message declaration 3
nextline = sy-tabix + 1.
READ TABLE itokens INDEX nextline INTO watokens.
TRANSLATE watokens-str USING ''' '.
CONDENSE itokens-str.
SHIFT watokens-str LEFT DELETING LEADING space.
IF NOT watokens-str = 'SY-MSGID'.
wamessage-arbgb = watokens-str.
nextline = nextline + 4.
READ TABLE itokens INDEX nextline INTO watokens.
TRANSLATE watokens-str USING ''' '.
CONDENSE watokens-str.
SHIFT watokens-str LEFT DELETING LEADING space.
wamessage-msgnr = watokens-str.
ELSE.
workingonmessage = false.
ENDIF.
ELSE.
IF stringlength >= 5 AND itokens-str+4(1) = '('.
* Message declaration 4
wamessage-msgnr = itokens-str+1(3).
SHIFT itokens-str LEFT UP TO '('.
REPLACE '(' INTO itokens-str WITH space.
REPLACE ')' INTO itokens-str WITH space.
CONDENSE itokens-str.
wamessage-arbgb = itokens-str.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
* find the message text
IF NOT wamessage-arbgb IS INITIAL AND NOT wamessage-msgnr IS INITIAL AND wamessage-text IS INITIAL.
SELECT SINGLE text
FROM t100
INTO wamessage-text
WHERE sprsl = sy-langu
AND arbgb = wamessage-arbgb
AND msgnr = wamessage-msgnr.
ENDIF.
* Append the message
IF NOT wamessage IS INITIAL.
* Don't append the message if we already have it listed
READ TABLE ilocmessages WITH KEY arbgb = wamessage-arbgb
msgnr = wamessage-msgnr
INTO wamessagecomparison.
IF sy-subrc <> 0.
APPEND wamessage TO ilocmessages.
ENDIF.
CLEAR wamessage.
workingonmessage = false.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. "scanForMessages
*-------------------------------------------------------------------------------------------------------
* scanForTables... Search each program for dictionary tables
*-------------------------------------------------------------------------------------------------------
FORM scanfortables USING VALUE(programname)
VALUE(customeronly)
VALUE(customernamerange)
ilocdictionary LIKE idictionary[].
DATA: iincludelines TYPE STANDARD TABLE OF string WITH HEADER LINE.
DATA: itokens TYPE STANDARD TABLE OF stokes WITH HEADER LINE.
DATA: istatements TYPE STANDARD TABLE OF sstmnt WITH HEADER LINE.
DATA: ikeywords TYPE STANDARD TABLE OF text20 WITH HEADER LINE.
DATA: wadictionary TYPE tdicttable.
DATA: wadictionarycomparison TYPE tdicttable.
DATA: castprogramname TYPE program.
* Read the program code from the textpool.
castprogramname = programname.
READ REPORT castprogramname INTO iincludelines.
APPEND tables TO ikeywords.
SCAN ABAP-SOURCE iincludelines TOKENS INTO itokens WITH INCLUDES STATEMENTS INTO istatements KEYWORDS FROM ikeywords.
CLEAR iincludelines[].
SORT itokens ASCENDING BY str.
DELETE itokens WHERE str = tables.
LOOP AT itokens.
IF NOT customeronly IS INITIAL.
TRY.
IF ( itokens-str+0(1) <> 'Y' OR itokens-str+0(1) <> 'Z' OR itokens-str NS customernamerange ).
CONTINUE.
ENDIF.
CATCH cx_sy_range_out_of_bounds INTO objruntimeerror.
ENDTRY.
ENDIF.
wadictionary-tablename = itokens-str.
* Don't append the object if we already have it listed
READ TABLE ilocdictionary INTO wadictionarycomparison WITH KEY tablename = wadictionary-tablename.
IF sy-subrc <> 0.
PERFORM findtabledescription USING wadictionary-tablename
wadictionary-tabletitle.
PERFORM findtabledefinition USING wadictionary-tablename
wadictionary-istructure[].
APPEND wadictionary TO ilocdictionary.
ENDIF.
ENDLOOP.
ENDFORM. "scanForTables
*----------------------------------------------------------------------------------------------------------------------
* retrievePrograms... find programs and sub objects from SAP DB
*----------------------------------------------------------------------------------------------------------------------
FORM retrieveprograms USING ilocprogram LIKE iprograms[]
ilocfunctions LIKE ifunctions[]
rangeprogram LIKE soprogramname[]
rangeauthor LIKE soauthor[]
VALUE(custnamerange)
VALUE(alsomodifiedbyauthor)
VALUE(customerprogsonly)
VALUE(getmessages)
VALUE(gettextelements)
VALUE(getcustdictstructures)
VALUE(getfunctions)
VALUE(getincludes)
VALUE(getscreens)
VALUE(recursivefuncsearch)
VALUE(recursiveincludesearch)
VALUE(getlocalobjects)
VALUE(package).
DATA: warangeprogram LIKE LINE OF rangeprogram.
IF rangeprogram[] IS INITIAL.
* We are finding all programs by an author
PERFORM findallprogramsforauthor USING ilocprogram[]
rangeprogram[]
rangeauthor[]
custnamerange
alsomodifiedbyauthor
customerprogsonly
getlocalobjects
package.
ELSE.
READ TABLE rangeprogram INDEX 1 INTO warangeprogram.
IF warangeprogram-low CS asterix.
PERFORM findprogramsbywildcard USING ilocprogram[]
rangeprogram[]
rangeauthor[]
custnamerange
customerprogsonly
getlocalobjects
package.
ELSE.
PERFORM checkprogramdoesexist USING ilocprogram[]
rangeprogram[].
ENDIF.
ENDIF.
* Find extra items
PERFORM scanforadditionalprogstuff USING ilocprogram[]
ilocfunctions[]
gettextelements
getmessages
getscreens
getcustdictstructures
getfunctions
getincludes
customerprogsonly
custnamerange
recursiveincludesearch
recursivefuncsearch.
ENDFORM. "retrievePrograms
*-------------------------------------------------------------------------------------------------------
* checkProgramDoesExist...
*-------------------------------------------------------------------------------------------------------
FORM checkprogramdoesexist USING ilocprogram LIKE iprograms[]
rangeprogram LIKE soprogramname[].
DATA: waprogram TYPE tprogram.
* Check to see if the program is an executable program
SELECT SINGLE progname
subc
INTO (waprogram-progname, waprogram-subc)
FROM reposrc
WHERE progname IN rangeprogram
AND ( subc = '1' OR
subc = 'I' OR
subc = 'M' OR
subc = 'S' ).
IF NOT waprogram-progname IS INITIAL.
APPEND waprogram TO ilocprogram.
ENDIF.
ENDFORM. "checkProgramDoesExist
*-------------------------------------------------------------------------------------------------------
* findAllProgramsForAuthor...
*-------------------------------------------------------------------------------------------------------
FORM findallprogramsforauthor USING ilocprogram LIKE iprograms[]
rangeprogram LIKE soprogramname[]
rangeauthor LIKE soauthor[]
VALUE(custnamerange)
VALUE(alsomodifiedbyauthor)
VALUE(customerprogsonly)
VALUE(getlocalobjects)
VALUE(package).
DATA: altcustomernamerange TYPE string.
FIELD-SYMBOLS: <waprogram> TYPE tprogram.
DATA: genflag TYPE genflag.
* build up the customer name range used for select statements
CONCATENATE custnamerange '%' INTO altcustomernamerange.
* select by name and author
IF NOT alsomodifiedbyauthor IS INITIAL.
* Programs modified by author
* Program to search for is an executable program
IF customerprogsonly IS INITIAL.
* Select all programs
SELECT progname
subc
FROM reposrc
APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
WHERE progname IN rangeprogram
AND cnam IN rangeauthor
AND ( subc = '1' OR subc = 'M' OR subc = 'S' ).
ELSE.
* Select only customer specific programs
SELECT progname
subc
FROM reposrc
APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
WHERE progname IN rangeprogram
AND ( progname LIKE altcustomernamerange
OR progname LIKE 'Z%'
OR progname LIKE 'Y%'
OR progname LIKE 'SAPMZ%'
OR progname LIKE 'SAPMY%')
AND cnam IN rangeauthor
AND ( subc = '1' OR subc = 'M' OR subc = 'S' ).
ENDIF.
ELSE.
* Programs created by author
IF customerprogsonly IS INITIAL.
* Select all programs
SELECT progname
subc
FROM reposrc
APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
WHERE progname IN rangeprogram
AND ( subc = '1' OR subc = 'M' OR subc = 'S' )
AND ( cnam IN rangeauthor OR unam IN rangeauthor ).
ELSE.
* Select only customer specific programs
SELECT progname
subc
FROM reposrc
APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
WHERE progname IN rangeprogram
AND ( progname LIKE altcustomernamerange
OR progname LIKE 'Z%'
OR progname LIKE 'Y%'
OR progname LIKE 'SAPMZ%'
OR progname LIKE 'SAPMY%')
AND ( subc = '1' OR subc = 'M' OR subc = 'S' )
AND ( cnam IN rangeauthor OR unam IN rangeauthor ).
ENDIF.
ENDIF.
* Delete any programs which are local objects
IF getlocalobjects IS INITIAL.
LOOP AT ilocprogram ASSIGNING <waprogram>.
SELECT SINGLE genflag
FROM tadiv
INTO genflag
WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name = <waprogram>-progname
AND devclass = '$TMP'.
IF sy-subrc = 0.
DELETE ilocprogram.
ENDIF.
ENDLOOP.
ENDIF.
* Delete any programs which are not in the specified package
IF NOT package IS INITIAL.
IF package CS '*'.
TRANSLATE package USING '*%'.
ENDIF.
LOOP AT ilocprogram ASSIGNING <waprogram>.
SELECT SINGLE genflag
FROM tadiv
INTO genflag
WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name = <waprogram>-progname
AND devclass LIKE package.
IF sy-subrc <> 0.
DELETE ilocprogram.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. "findAllProgramsForAuthor
*-------------------------------------------------------------------------------------------------------
* findProgramsByWildcard.. Search in the system for programs
*-------------------------------------------------------------------------------------------------------
FORM findprogramsbywildcard USING ilocprogram LIKE iprograms[]
VALUE(rangeprogram) LIKE soprogramname[]
VALUE(rangeauthor) LIKE soauthor[]
VALUE(custnamerange)
VALUE(customerprogsonly)
VALUE(getlocalobjects)
VALUE(package).
DATA: altcustomernamerange TYPE string.
FIELD-SYMBOLS: <waprogram> TYPE tprogram.
DATA: genflag TYPE genflag.
IF customerprogsonly IS INITIAL.
* build up the customer name range used for select statements
IF custnamerange <> '^'.
CONCATENATE custnamerange '%' INTO altcustomernamerange.
SELECT progname
subc
FROM reposrc
APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
WHERE progname IN rangeprogram
AND progname LIKE altcustomernamerange
AND ( subc = '1' OR subc = 'M' OR subc = 'S' )
AND ( cnam IN rangeauthor OR unam IN rangeauthor ).
ELSE.
SELECT progname
subc
FROM reposrc
APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
WHERE progname IN rangeprogram
AND ( subc = '1' OR subc = 'M' OR subc = 'S' )
AND ( cnam IN rangeauthor OR unam IN rangeauthor ).
ENDIF.
ELSE.
* Only customer programs
IF custnamerange <> '^'.
CONCATENATE custnamerange '%' INTO altcustomernamerange.
SELECT progname
subc
FROM reposrc
APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
WHERE progname IN rangeprogram
AND ( progname LIKE altcustomernamerange
OR progname LIKE 'Z%'
OR progname LIKE 'Y%'
OR progname LIKE 'SAPMZ%'
OR progname LIKE 'SAPMY%')
AND ( subc = '1' OR subc = 'M' OR subc = 'S' )
AND ( cnam IN rangeauthor OR unam IN rangeauthor ).
ELSE.
SELECT progname
subc
FROM reposrc
APPENDING CORRESPONDING FIELDS OF TABLE ilocprogram
WHERE progname IN rangeprogram
AND ( progname LIKE 'Z%'
OR progname LIKE 'Y%'
OR progname LIKE 'SAPMZ%'
OR progname LIKE 'SAPMY%')
AND ( subc = '1' OR subc = 'M' OR subc = 'S' )
AND ( cnam IN rangeauthor OR unam IN rangeauthor ).
ENDIF.
ENDIF.
* Delete any programs which are local objects
IF getlocalobjects IS INITIAL.
LOOP AT ilocprogram ASSIGNING <waprogram>.
SELECT SINGLE genflag
FROM tadiv
INTO genflag
WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name = <waprogram>-progname
AND devclass = '$TMP'.
IF sy-subrc = 0.
DELETE ilocprogram.
ENDIF.
ENDLOOP.
ENDIF.
* Delete any programs which are not in the specified package
IF NOT package IS INITIAL.
LOOP AT ilocprogram ASSIGNING <waprogram>.
SELECT SINGLE genflag
FROM tadiv
INTO genflag
WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name = <waprogram>-progname
AND devclass <> package.
IF sy-subrc = 0.
DELETE ilocprogram.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. "findProgramsByWildcard
*-------------------------------------------------------------------------------------------------------
* scanForAdditionalProgStuff...
*-------------------------------------------------------------------------------------------------------
FORM scanforadditionalprogstuff USING ilocprogram LIKE iprograms[]
ilocfunctions LIKE ifunctions[]
VALUE(gettextelements)
VALUE(getmessages)
VALUE(getscreens)
VALUE(getcustdictstructures)
VALUE(getfunctions)
VALUE(getincludes)
VALUE(customeronly)
VALUE(customernamerange)
VALUE(recursiveincludesearch)
VALUE(recursivefuncsearch).
DATA: waprogram TYPE tprogram.
DATA: wainclude TYPE tinclude.
DATA: mytabix TYPE sytabix.
* Best to find all the includes used in a program first
IF NOT getincludes IS INITIAL.
LOOP AT ilocprogram INTO waprogram.
mytabix = sy-tabix.
PERFORM scanforincludeprograms USING waprogram-progname
recursiveincludesearch
customeronly
customernamerange
waprogram-iincludes[].
MODIFY ilocprogram FROM waprogram INDEX mytabix.
ENDLOOP.
ENDIF.
* Once we have a list of all the includes we need to loop round them an select all the other objects
LOOP AT ilocprogram INTO waprogram.
mytabix = sy-tabix.
PERFORM findprogramdetails USING waprogram-progname
waprogram-subc
waprogram-programtitle
waprogram
gettextelements
getmessages
getscreens
getcustdictstructures
customeronly
customernamerange.
* Find any screens
IF NOT getscreens IS INITIAL.
PERFORM findprogramscreenflow USING waprogram.
ENDIF.
LOOP AT waprogram-iincludes INTO wainclude.
PERFORM findprogramdetails USING wainclude-includename
'I'
wainclude-includetitle
waprogram
gettextelements
getmessages
getscreens
getcustdictstructures
customeronly
customernamerange.
ENDLOOP.
MODIFY ilocprogram FROM waprogram INDEX mytabix.
ENDLOOP.
* Now we have all the program includes and details we need to find extra functions
IF NOT getfunctions IS INITIAL.
LOOP AT ilocprogram INTO waprogram.
* Find any functions defined in the code
PERFORM scanforfunctions USING waprogram-progname
waprogram-progname
space
space
customeronly
customernamerange
ilocfunctions[].
ENDLOOP.
ENDIF.
* We have a list of all the functions so lets go and find details and other function calls
PERFORM scanforadditionalfuncstuff USING ilocfunctions[]
recursiveincludesearch
recursivefuncsearch
getincludes
getfunctions
getcustdictstructures
getmessages
customeronly
customernamerange.
ENDFORM. "scanForAdditionalProgStuff
*-------------------------------------------------------------------------------------------------------
* findProgramDetails...
*-------------------------------------------------------------------------------------------------------
FORM findprogramdetails USING VALUE(programname)
VALUE(programtype)
programtitle
waprogram TYPE tprogram
VALUE(gettextelements)
VALUE(getmessages)
VALUE(getscreens)
VALUE(getcustdictstructures)
VALUE(customeronly)
VALUE(customernamerange).
PERFORM findprogramorincludetitle USING programname
programtitle.
IF NOT gettextelements IS INITIAL.
* Find the program texts from out of the database.
PERFORM retrieveprogramtexts USING waprogram-iselectiontexts[]
waprogram-itextelements[]
programname.
ENDIF.
* Search for any GUI texts
IF NOT getscreens IS INITIAL AND ( programtype = 'M' OR programtype = '1' ).
PERFORM retrieveguititles USING waprogram-iguititle[]
programname.
ENDIF.
* Find individual messages
IF NOT getmessages IS INITIAL.
IF programtype = 'M' OR programtype = '1'.
PERFORM findmainmessageclass USING programname
waprogram-messageclass.
ENDIF.
PERFORM scanformessages USING programname
waprogram-messageclass
waprogram-imessages[].
ENDIF.
IF NOT getcustdictstructures IS INITIAL.
PERFORM scanfortables USING programname
customeronly
customernamerange
waprogram-idictstruct[].
PERFORM scanforlikeortype USING programname
customeronly
customernamerange
waprogram-idictstruct[].
ENDIF.
ENDFORM. "findProgramDetails
*-------------------------------------------------------------------------------------------------------
* findProgramScreenFlow...
*-------------------------------------------------------------------------------------------------------
FORM findprogramscreenflow USING waprogram TYPE tprogram.
DATA: iflow TYPE STANDARD TABLE OF tscreenflow WITH HEADER LINE.
CALL FUNCTION 'DYNPRO_PROCESSINGLOGIC'
EXPORTING
rep_name = waprogram-progname
TABLES
scr_logic = iflow.
SORT iflow ASCENDING BY screen.
DELETE ADJACENT DUPLICATES FROM iflow COMPARING screen.
IF waprogram-subc <> 'M'.
DELETE iflow WHERE screen >= '1000' AND screen <= '1099'.
ENDIF.
LOOP AT iflow.
APPEND iflow TO waprogram-iscreenflow.
ENDLOOP.
ENDFORM. "findProgramScreenFlow