参考底表
标准底表:TRDIR, TSTC,DD02L,DD02T,TFDIR,TFTIT.
表名 | 描述 |
---|---|
TRDIR | System Table TRDIR |
TSTC | SAP Transaction Codes |
DD02L | SAP Tables |
DD02T | SAP DD: SAP Table Texts |
TFDIR | Function Module |
TFTIT | Function Module Short Text |
RFC类其他可参考底表:
ENLFDIR,FUNCT,FUPARAREF,FUPARAREF_ENHA,RSFBTYPEIN,
RSFBTYPEIT,RSINFDIR,TFTIT ,TLIBG ,TLIBT,TFDIR,TFTIT,V_FDIR.
SAP标准底表 | |
ENLFDIR | Additional Attributes for Function Modules |
FUNCT | Function Module Short Texts |
FUPARAREF | Parameters of function modules |
FUPARAREF_ENHA | Parameters of function modules |
RSFBTYPEIN | Possible Type Specifications |
RSFBTYPEIT | Text for RSFBTYPEIN |
RSINFDIR | Inactive table for TFDIR and ENLFDIR |
TFTIT | Function Module Short Text |
TLIBG | Person responsible for function class |
TLIBT | Function Group Short Texts |
TFDIR | Function Module |
TFTIT | Function Module Short Text |
V_FDIR | View for finding function modules |
实现功能
1.报表查询
2.函数(RFC)查询
3.数据库表查询
源代码
*&---------------------------------------------------------------------*
*& Report ZSEARCH_RERPORT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------
REPORT zsearch_report.
TABLES: trdir, tstc,dd02l,dd02t,tfdir,tftit.
DATA: BEGIN OF gs_data,
sel TYPE boolean, " 用于选择多行
name TYPE trdir-name, " 程序名
subc TYPE trdir-subc, " 程序类型
rstat TYPE trdir-rstat, " 状态
tcode TYPE tstc-tcode, " 事务码
ttext TYPE tstct-ttext, " 事务码描述
cnam TYPE trdir-cnam, " 创建者
cdat TYPE trdir-cdat, " 创建日期
unam TYPE trdir-unam, " 最后修改人
udat TYPE trdir-udat, " 修改日期
END OF gs_data.
DATA: gt_data LIKE TABLE OF gs_data. " ALV显示內表
DATA: line TYPE i." ALV行数
TYPES:BEGIN OF gty_tab,
tabname TYPE dd02t-tabname,
ddlanguage TYPE dd02t-ddlanguage,
as4local TYPE dd02t-as4local,
as4vers TYPE dd02t-as4vers,
ddtext TYPE dd02t-ddtext,
tabclass TYPE dd02l-tabclass,
as4user TYPE dd02l-as4user,
as4date TYPE dd02l-as4date,
as4time TYPE dd02l-as4time,
mainflag TYPE dd02l-mainflag,
contflag TYPE dd02l-contflag,
END OF gty_tab.
DATA:gt_table TYPE TABLE OF gty_tab,
gs_table LIKE LINE OF gt_table.
TYPES:BEGIN OF gty_rfc.
INCLUDE TYPE tfdir.
TYPES: spras TYPE tftit-spras,
stext TYPE tftit-stext,
END OF gty_rfc.
DATA:gt_rfc TYPE TABLE OF gty_rfc,
gs_rfc LIKE LINE OF gt_rfc.
" 选择屏幕
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_name FOR trdir-name MODIF ID m1, " 程序名
s_tcode FOR tstc-tcode MODIF ID m1, " 事务码
s_cnam FOR trdir-cnam MODIF ID m1, " 创建者
s_unam FOR trdir-unam MODIF ID m1, " 最后修改人
s_subc FOR trdir-subc DEFAULT 1 MODIF ID m1, " 程序类型
s_rstat FOR trdir-rstat MODIF ID m1. " 状态
SELECT-OPTIONS: s_tname FOR dd02t-tabname MODIF ID m2,
s_lang FOR dd02t-ddlanguage MODIF ID m2,
s_status FOR dd02t-as4local MODIF ID m2,
s_vers FOR dd02t-as4vers MODIF ID m2,
s_des FOR dd02t-ddtext MODIF ID m2,
s_class FOR dd02l-tabclass MODIF ID m2,
s_user FOR dd02l-as4user MODIF ID m2,
s_date FOR dd02l-as4date MODIF ID m2,
s_time FOR dd02l-as4time MODIF ID m2.
SELECT-OPTIONS: s_fmnam FOR tfdir-funcname MODIF ID m3,
s_pname FOR tfdir-pname MODIF ID m3,
s_inclu FOR tfdir-include MODIF ID m3,
s_stext FOR tftit-stext MODIF ID m3,
s_spras FOR tftit-spras MODIF ID m3.
PARAMETERS: p_fmnam TYPE tfdir-funcname MODIF ID m3,
p_stext TYPE tftit-stext MODIF ID m3.
SELECTION-SCREEN END OF BLOCK b1.
" F8事件
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_report RADIOBUTTON GROUP g1 DEFAULT 'X' MODIF ID p1 USER-COMMAND u1,
p_rfc RADIOBUTTON GROUP g1 MODIF ID p1,
p_tab RADIOBUTTON GROUP g1 MODIF ID p1.
SELECTION-SCREEN END OF BLOCK b2.
INITIALIZATION.
AT SELECTION-SCREEN OUTPUT.
* IF p_report EQ 'X'.
LOOP AT SCREEN.
IF p_report EQ 'X'.
IF screen-group1 EQ 'M3'
OR screen-group1 EQ 'M2'
* AND SCREEN-GROUP1 NE 'B1'
.
screen-active = '0'.
ELSE.
screen-active = '1'.
ENDIF.
* MODIFY SCREEN.
* ENDLOOP.
ELSEIF p_rfc = 'X'.
* LOOP AT SCREEN.
IF screen-group1 EQ 'M1'
OR screen-group1 EQ 'M2'..
screen-active = '0'.
ELSE.
screen-active = '1'.
ENDIF.
ELSEIF p_tab = 'X'.
IF screen-group1 EQ 'M1'
OR screen-group1 EQ 'M3'.
screen-active = '0'.
ELSE.
screen-active = '1'.
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
* ENDIF.
START-OF-SELECTION.
IF p_report = 'X'.
IF s_name[] IS INITIAL AND " 程序名
s_cnam[] IS INITIAL AND " 创建者
s_unam[] IS INITIAL AND " 最后修改人
s_subc[] IS INITIAL AND " 程序类型
s_tcode[] IS INITIAL AND " 事务码
s_rstat[] IS INITIAL. " 状态
MESSAGE '请至少输入一个条件' TYPE 'S' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
PERFORM get_data.
IF gt_data[] IS INITIAL.
MESSAGE '无符合条件的记录' TYPE 'S' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
PERFORM alv_data.
ELSEIF p_tab = 'X'.
* MESSAGE '请期待后续更新' TYPE 'I'.
IF
s_tname[] IS INITIAL AND
s_lang[] IS INITIAL AND
s_status[] IS INITIAL AND
s_vers[] IS INITIAL AND
s_des[] IS INITIAL AND
s_class[] IS INITIAL AND
s_user[] IS INITIAL AND
s_date[] IS INITIAL AND
s_time[] IS INITIAL.
MESSAGE '请至少输入一个条件' TYPE 'S' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
PERFORM get_data_tab.
IF gt_table IS INITIAL.
MESSAGE '无符合条件的记录' TYPE 'S' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
PERFORM alv_data_tab.
ELSEIF p_rfc = 'X'.
* MESSAGE '请期待后续更新' TYPE 'I'.
IF s_fmnam[] IS INITIAL AND
s_pname[] IS INITIAL AND
s_inclu[] IS INITIAL AND
s_stext[] IS INITIAL AND
s_spras[] IS INITIAL AND
p_stext IS INITIAL AND
p_fmnam IS INITIAL..
MESSAGE '请至少输入一个条件' TYPE 'S' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
PERFORM get_data_rfc.
IF gt_rfc IS INITIAL.
MESSAGE '无符合条件的记录' TYPE 'S' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
PERFORM alv_data_rfc.
ENDIF.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text 获取数据
*----------------------------------------------------------------------*
FORM get_data.
DATA: BEGIN OF ls_tstc,
tcode TYPE tstc-tcode,
ttext TYPE tstct-ttext,
END OF ls_tstc.
DATA: lt_tstc LIKE TABLE OF ls_tstc.
" 输入事务码时
IF s_tcode[] IS NOT INITIAL.
SELECT
a~tcode
b~name
b~subc
b~rstat
b~cnam
b~cdat
b~unam
b~udat
c~ttext
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM tstc AS a
INNER JOIN trdir AS b ON a~pgmna = b~name
INNER JOIN tstct AS c ON a~tcode = c~tcode
WHERE a~tcode IN s_tcode
AND b~name IN s_name " 程序名
AND b~cnam IN s_cnam " 创建者
AND b~unam IN s_unam " 最后修改人
AND b~subc IN s_subc " 程序类型
AND b~rstat IN s_rstat. " 状态
ELSE.
" 没有输入事务码时
SELECT
a~name
a~subc
a~rstat
a~cnam
a~cdat
a~unam
a~udat
b~tcode
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM trdir AS a
LEFT JOIN tstc AS b ON a~name = b~pgmna
WHERE a~name IN s_name " 程序名
AND a~cnam IN s_cnam " 创建者
AND a~unam IN s_unam " 最后修改人
AND a~subc IN s_subc " 程序类型
AND a~rstat IN s_rstat. " 状态
IF gt_data[] IS NOT INITIAL.
" 查询事务码描述文本
SELECT
tcode
ttext
INTO CORRESPONDING FIELDS OF TABLE lt_tstc
FROM tstct
FOR ALL ENTRIES IN gt_data
WHERE tcode = gt_data-tcode.
SORT lt_tstc BY tcode." 先排序
LOOP AT gt_data INTO gs_data.
READ TABLE lt_tstc INTO ls_tstc WITH KEY tcode = gs_data-tcode BINARY SEARCH.
IF sy-subrc EQ 0.
gs_data-ttext = ls_tstc-ttext.
MODIFY gt_data FROM gs_data TRANSPORTING ttext.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
" 统计內表行数
DESCRIBE TABLE gt_data LINES line.
" 排序
SORT gt_data BY cnam cdat.
ENDFORM. "get_data
*&---------------------------------------------------------------------*
*& Form alv_data
*&---------------------------------------------------------------------*
* text 显示ALV数据
*----------------------------------------------------------------------*
FORM alv_data.
DATA: fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
layout TYPE slis_layout_alv.
PERFORM get_layout CHANGING layout. " alv布局
PERFORM get_fieldcat TABLES fieldcat. " 控制报表显示哪些栏位
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid " 程序名
is_layout = layout " 布局
* i_callback_pf_status_set = 'PFSTATUS_FORM' " STATUS
i_callback_user_command = 'USER_COMMAND_FORM' " 定义按钮的功能
it_fieldcat = fieldcat[] " alv栏目(显示字段)内表
TABLES
t_outtab = gt_data " 将内表数据赋给ALV
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. "alv_data
*&---------------------------------------------------------------------*
*& Form get_layout
*&---------------------------------------------------------------------*
* text ALV布局设置
*----------------------------------------------------------------------*
* -->C_LAYOUT text
*----------------------------------------------------------------------*
FORM get_layout CHANGING c_layout TYPE slis_layout_alv.
CLEAR: c_layout.
c_layout-colwidth_optimize = 'X'." 宽度自动调节
* c_layout-box_fieldname = 'SEL'. " 选择多行
c_layout-zebra = 'X'. " 颜色交替显示
ENDFORM. "get_layout
*&---------------------------------------------------------------------*
*& Form USER_COMMAND_FORM
*&---------------------------------------------------------------------*
* text 自定义按钮功能
*----------------------------------------------------------------------*
* -->R_UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
FORM user_command_form USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
READ TABLE gt_data INTO gs_data INDEX rs_selfield-tabindex.
PERFORM command_action USING rs_selfield-fieldname.
* IF sy-subrc EQ 0 AND gs_data-tcode IS NOT INITIAL.
* CASE r_ucomm.
* WHEN '&IC1'. " 双击事件
* CALL TRANSACTION gs_data-tcode. " 调用事务码,运行程序
* WHEN OTHERS.
* ENDCASE.
* ENDIF.
ENDFORM. "USER_COMMAND_FORM
FORM command_action USING fieldname..
TRANSLATE fieldname TO UPPER CASE.
CASE fieldname.
WHEN 'NAME'.
SET PARAMETER ID 'RID' FIELD gs_data-name.
IF sy-subrc = 0.
CALL TRANSACTION 'SE38' AND SKIP FIRST SCREEN.
ENDIF.
WHEN 'TCODE'.
IF gs_data-tcode IS NOT INITIAL.
CALL TRANSACTION gs_data-tcode. " 调用事务码,运行程序
ENDIF.
ENDCASE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form get_fieldcat
*&---------------------------------------------------------------------*
* text 显示字段
*----------------------------------------------------------------------*
* -->CT_TAB text
*----------------------------------------------------------------------*
FORM get_fieldcat TABLES ct_tab TYPE slis_t_fieldcat_alv.
DATA: fcat TYPE slis_fieldcat_alv.
DEFINE add_fcat.
clear fcat.
fcat-fieldname = &1. " 字段名
fcat-seltext_l = &2. " 显示字段文本
fcat-seltext_m = &2.
fcat-seltext_s = &2.
fcat-key = &3. " 主键
fcat-hotspot = &4. " 链接
fcat-checkbox = &5. " 复选框
fcat-edit = &6. " 是否可修改
fcat-ref_tabname = &7. " 参考表
fcat-ref_fieldname = &8. " 参考表字段
append fcat to ct_tab.
END-OF-DEFINITION.
add_fcat 'NAME' '程序名' '' '' '' '' '' ''.
add_fcat 'SUBC' '程序类型' '' '' '' '' 'TRDIR' 'SUBC'.
add_fcat 'RSTAT' '状态' '' '' '' '' 'TRDIR' 'RSTAT'.
add_fcat 'TCODE' '事务码' '' '' '' '' '' ''.
add_fcat 'TTEXT' '事务码描述' '' '' '' '' '' ''.
add_fcat 'CNAM' '创建者' '' '' '' '' '' ''.
add_fcat 'CDAT' '创建日期' '' '' '' '' '' ''.
add_fcat 'UNAM' '最后修改人' '' '' '' '' '' ''.
add_fcat 'UDAT' '修改日期' '' '' '' '' '' ''.
ENDFORM. "get_fieldcat
*&---------------------------------------------------------------------*
*& Form pfstatus_form
*&---------------------------------------------------------------------*
* text STATUS
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM pfstatus_form USING rt_extab TYPE slis_t_extab.
SET TITLEBAR 'TITLE_BAR' WITH line. " 标题
SET PF-STATUS 'STATUS_BAR'. " 工具条
ENDFORM. "pfstatus_form </span
"Get data of table
FORM get_data_tab.
SELECT
t~tabname ,
t~ddlanguage,
t~as4local ,
t~as4vers ,
t~ddtext ,
tabclass ,
as4user ,
as4date ,
as4time ,
mainflag ,
contflag
INTO CORRESPONDING FIELDS OF TABLE @gt_table
FROM dd02t AS t
INNER JOIN dd02l AS l ON t~tabname = l~tabname
AND t~as4local = l~as4local
AND t~as4vers = l~as4vers
WHERE t~tabname IN @s_tname[] AND
t~ddlanguage IN @s_lang[] AND
t~as4local IN @s_status[] AND
t~as4vers IN @s_vers[] AND
t~ddtext IN @s_des[] AND
tabclass IN @s_class[] AND
as4user IN @s_user[] AND
as4date IN @s_date[] AND
as4time IN @s_time[] .
IF gt_table IS INITIAL.
MESSAGE '未找到相关数据' TYPE 'I'.
EXIT.
ENDIF.
CLEAR line.
DESCRIBE TABLE gt_table LINES line.
ENDFORM.
"Display table details
FORM alv_data_tab.
DATA: fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
layout TYPE slis_layout_alv.
PERFORM get_layout CHANGING layout. " alv布局
PERFORM get_fieldcat1 TABLES fieldcat. " 控制报表显示哪些栏位
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid " 程序名
is_layout = layout " 布局
* i_callback_pf_status_set = 'PFSTATUS_FORM' " STATUS
i_callback_user_command = 'USER_COMMAND_FORM1' " 定义按钮的功能
it_fieldcat = fieldcat[] " alv栏目(显示字段)内表
TABLES
t_outtab = gt_table " 将内表数据赋给ALV
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
FORM user_command_form1 USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
READ TABLE gt_table INTO gs_table INDEX rs_selfield-tabindex.
PERFORM command_action1 USING rs_selfield-fieldname.
* IF sy-subrc EQ 0 AND gs_data-tcode IS NOT INITIAL.
* CASE r_ucomm.
* WHEN '&IC1'. " 双击事件
* CALL TRANSACTION gs_data-tcode. " 调用事务码,运行程序
* WHEN OTHERS.
* ENDCASE.
* ENDIF.
ENDFORM. "USER_COMMAND_FORM
FORM command_action1 USING fieldname..
TRANSLATE fieldname TO UPPER CASE.
CASE fieldname.
WHEN 'TABNAME'.
IF gs_table-tabclass = 'INTTAB'.
SET PARAMETER ID 'DTYP' FIELD gs_table-tabname.
SET PARAMETER ID 'CLASSDDTYP' FIELD 'X'.
ELSE.
SET PARAMETER ID 'DTB' FIELD gs_table-tabname.
SET PARAMETER ID 'CLASSTAB' FIELD 'X'.
ENDIF.
IF sy-subrc = 0.
CALL TRANSACTION 'SE11' AND SKIP FIRST SCREEN.
ENDIF.
* WHEN 'TCODE'.
* IF gs_data-tcode IS NOT INITIAL.
* CALL TRANSACTION gs_data-tcode. " 调用事务码,运行程序
* ENDIF.
ENDCASE.
ENDFORM.
"Table dispaly set
FORM get_fieldcat1 TABLES ct_tab TYPE slis_t_fieldcat_alv.
DATA: fcat TYPE slis_fieldcat_alv.
DEFINE add_fcat.
clear fcat.
fcat-fieldname = &1. " 字段名
fcat-seltext_l = &2. " 显示字段文本
fcat-seltext_m = &2.
fcat-seltext_s = &2.
fcat-key = &3. " 主键
fcat-hotspot = &4. " 链接
fcat-checkbox = &5. " 复选框
fcat-edit = &6. " 是否可修改
fcat-ref_tabname = &7. " 参考表
fcat-ref_fieldname = &8. " 参考表字段
append fcat to ct_tab.
END-OF-DEFINITION.
add_fcat 'TABNAME ' ' ' '' '' '' '' 'DD02T' 'TABNAME ' .
add_fcat 'DDLANGUAGE' ' ' '' '' '' '' 'DD02T' 'DDLANGUAGE'.
add_fcat 'AS4LOCAL ' ' ' '' '' '' '' 'DD02T' 'AS4LOCAL '.
add_fcat 'AS4VERS ' ' ' '' '' '' '' 'DD02T' 'AS4VERS '.
add_fcat 'DDTEXT ' ' ' '' '' '' '' 'DD02T' 'DDTEXT '.
add_fcat 'TABCLASS ' ' ' '' '' '' '' 'DD02L' 'TABCLASS '.
add_fcat 'AS4USER ' ' ' '' '' '' '' 'DD02L' 'AS4USER '.
add_fcat 'AS4DATE ' ' ' '' '' '' '' 'DD02L' 'AS4DATE '.
add_fcat 'AS4TIME ' ' ' '' '' '' '' 'DD02L' 'AS4TIME '.
add_fcat 'MAINFLAG ' ' ' '' '' '' '' 'DD02L' 'MAINFLAG '.
add_fcat 'CONTFLAG ' ' ' '' '' '' '' 'DD02L' 'CONTFLAG '.
ENDFORM. "get_fieldcat
FORM get_data_rfc.
*RANGES:R_STEXT FOR TFTIT-STEXT.
*CLEAR:R_STEXT[],R_STEXT.
DATA:lv_stext1 TYPE tftit-stext,
lv_stext2 TYPE tftit-stext,
lv_stext3 TYPE tftit-stext.
DATA:lv_fmnam1 TYPE tfdir-funcname,
lv_fmnam2 TYPE tfdir-funcname,
lv_fmnam3 TYPE tfdir-funcname.
CLEAR:lv_stext1,lv_stext2,lv_stext3,
lv_fmnam1,lv_fmnam2,lv_fmnam3.
IF p_stext IS NOT INITIAL.
lv_stext1 = '%' && p_stext.
lv_stext2 = '%' && p_stext && '%'.
lv_stext3 = p_stext && '%'.
ENDIF.
IF p_fmnam IS NOT INITIAL.
lv_fmnam1 = '%' && p_fmnam.
lv_fmnam2 = '%' && p_fmnam && '%'.
lv_fmnam3 = p_fmnam && '%'.
ENDIF.
IF p_stext IS NOT INITIAL
AND p_fmnam IS INITIAL. .
SELECT
r~funcname,
pname,
include,
freedate,
appl,
mand,
fmode,
host,
utask,
pname_main,
spras,
stext
INTO CORRESPONDING FIELDS OF TABLE @gt_rfc
FROM tfdir AS r
INNER JOIN tftit AS t ON r~funcname = t~funcname
WHERE r~funcname IN @s_fmnam[] AND
r~pname IN @s_pname[] AND
r~include IN @s_inclu[] AND
t~stext IN @s_stext[] AND
( t~stext = @p_stext OR
t~stext LIKE @lv_stext1 OR
t~stext LIKE @lv_stext2 OR
t~stext LIKE @lv_stext3 ) AND
t~spras IN @s_spras[].
ELSEIF p_fmnam IS NOT INITIAL
AND p_stext IS INITIAL.
SELECT
r~funcname,
pname,
include,
freedate,
appl,
mand,
fmode,
host,
utask,
pname_main,
spras,
stext
INTO CORRESPONDING FIELDS OF TABLE @gt_rfc
FROM tfdir AS r
INNER JOIN tftit AS t ON r~funcname = t~funcname
WHERE r~funcname IN @s_fmnam[] AND
r~pname IN @s_pname[] AND
r~include IN @s_inclu[] AND
t~stext IN @s_stext[] AND
* ( t~stext = @p_stext OR
* t~stext LIKE @lv_stext1 OR
* t~stext LIKE @lv_stext2 OR
* t~stext LIKE @lv_stext3 ) AND
( r~funcname = @p_fmnam OR
r~funcname LIKE @lv_fmnam1 OR
r~funcname LIKE @lv_fmnam2 OR
r~funcname LIKE @lv_fmnam3
) AND
t~spras IN @s_spras[].
ELSEIF p_fmnam IS NOT INITIAL
AND p_stext IS NOT INITIAL..
SELECT
r~funcname,
pname,
include,
freedate,
appl,
mand,
fmode,
host,
utask,
pname_main,
spras,
stext
INTO CORRESPONDING FIELDS OF TABLE @gt_rfc
FROM tfdir AS r
INNER JOIN tftit AS t ON r~funcname = t~funcname
WHERE r~funcname IN @s_fmnam[] AND
r~pname IN @s_pname[] AND
r~include IN @s_inclu[] AND
t~stext IN @s_stext[] AND
( t~stext = @p_stext OR
t~stext LIKE @lv_stext1 OR
t~stext LIKE @lv_stext2 OR
t~stext LIKE @lv_stext3 ) AND
( r~funcname = @p_fmnam OR
r~funcname LIKE @lv_fmnam1 OR
r~funcname LIKE @lv_fmnam2 OR
r~funcname LIKE @lv_fmnam3
) AND
t~spras IN @s_spras[].
ELSE.
SELECT
r~funcname,
pname,
include,
freedate,
appl,
mand,
fmode,
host,
utask,
pname_main,
spras,
stext
INTO CORRESPONDING FIELDS OF TABLE @gt_rfc
FROM tfdir AS r
INNER JOIN tftit AS t ON r~funcname = t~funcname
WHERE r~funcname IN @s_fmnam[] AND
r~pname IN @s_pname[] AND
r~include IN @s_inclu[] AND
t~stext IN @s_stext[] AND
t~spras IN @s_spras[].
ENDIF.
IF gt_rfc IS INITIAL.
MESSAGE '未找到相关数据' TYPE 'I'.
EXIT.
ENDIF.
CLEAR line.
DESCRIBE TABLE gt_rfc LINES line.
ENDFORM.
FORM alv_data_rfc.
DATA: fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
layout TYPE slis_layout_alv.
PERFORM get_layout CHANGING layout. " alv布局
PERFORM get_fieldcat2 TABLES fieldcat. " 控制报表显示哪些栏位
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid " 程序名
is_layout = layout " 布局
* i_callback_pf_status_set = 'PFSTATUS_FORM' " STATUS
i_callback_user_command = 'USER_COMMAND_FORM2' " 定义按钮的功能
it_fieldcat = fieldcat[] " alv栏目(显示字段)内表
TABLES
t_outtab = gt_rfc " 将内表数据赋给ALV
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
FORM user_command_form2 USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
READ TABLE gt_rfc INTO gs_rfc INDEX rs_selfield-tabindex.
* PERFORM command_action1 USING rs_selfield-fieldname.
SET PARAMETER ID 'LIB' FIELD gs_rfc-funcname.
IF sy-subrc = 0.
CALL TRANSACTION 'SE37' AND SKIP FIRST SCREEN.
ENDIF.
* IF sy-subrc EQ 0 AND gs_data-tcode IS NOT INITIAL.
* CASE r_ucomm.
* WHEN '&IC1'. " 双击事件
* CALL TRANSACTION gs_data-tcode. " 调用事务码,运行程序
* WHEN OTHERS.
* ENDCASE.
* ENDIF.
ENDFORM. "USER_COMMAND_FORM
*FORM command_action2 USING fieldname..
* TRANSLATE fieldname TO UPPER CASE.
* CASE fieldname.
* WHEN 'TABNAME'.
* IF gs_table-tabclass = 'INTTAB'.
* SET PARAMETER ID 'DTYP' FIELD gs_table-tabname.
* ELSE.
* SET PARAMETER ID 'DTB' FIELD gs_table-tabname.
* ENDIF.
* IF sy-subrc = 0.
* CALL TRANSACTION 'SE11' AND SKIP FIRST SCREEN.
* ENDIF.
** WHEN 'TCODE'.
** IF gs_data-tcode IS NOT INITIAL.
** CALL TRANSACTION gs_data-tcode. " 调用事务码,运行程序
** ENDIF.
* ENDCASE.
*ENDFORM.
"Table dispaly set
FORM get_fieldcat2 TABLES ct_tab TYPE slis_t_fieldcat_alv.
DATA: fcat TYPE slis_fieldcat_alv.
DEFINE add_fcat.
clear fcat.
fcat-fieldname = &1. " 字段名
fcat-seltext_l = &2. " 显示字段文本
fcat-seltext_m = &2.
fcat-seltext_s = &2.
fcat-key = &3. " 主键
fcat-hotspot = &4. " 链接
fcat-checkbox = &5. " 复选框
fcat-edit = &6. " 是否可修改
fcat-ref_tabname = &7. " 参考表
fcat-ref_fieldname = &8. " 参考表字段
append fcat to ct_tab.
END-OF-DEFINITION.
add_fcat 'FUNCNAME' ' ' '' '' '' '' 'TFDIR' 'FUNCNAME' .
add_fcat 'PNAME ' ' ' '' '' '' '' 'TFDIR' 'PNAME ' .
add_fcat 'INCLUDE ' ' ' '' '' '' '' 'TFDIR' 'INCLUDE ' .
add_fcat 'FREEDATE' ' ' '' '' '' '' 'TFDIR' 'FREEDATE' .
add_fcat 'APPL ' ' ' '' '' '' '' 'TFDIR' 'APPL ' .
add_fcat 'MAND ' ' ' '' '' '' '' 'TFDIR' 'MAND ' .
add_fcat 'FMODE ' ' ' '' '' '' '' 'TFDIR' 'FMODE ' .
add_fcat 'HOST ' ' ' '' '' '' '' 'TFDIR' 'HOST ' .
add_fcat 'UTASK ' ' ' '' '' '' '' 'TFDIR' 'UTASK ' .
add_fcat 'PNAME_MAIN' '' '' '' '' '' 'TFDIR' 'PNAME_MAIN'.
add_fcat 'SPRAS ' ' ' '' '' '' '' 'TFTIT' 'SPRAS ' .
add_fcat 'STEXT ' ' ' '' '' '' '' 'TFTIT' 'STEXT ' .
ENDFORM. "get_fieldcat