ABAP 屏幕F4帮助 调用函数实现
值内表的数据最好参考一下系统字段 不然如果只是TYPE C 可能没有数据展示出来
"展示表
DATA:BEGIN OF t_tab OCCURS 0,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
END OF t_tab.
"要使用F4的屏幕元素
PARAMETERS:p_matnr(20) TYPE c .
"监听F4 事件
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr.
PERFORM frm_help.
*&---------------------------------------------------------------------*
*& Form FRM_HELP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_help .
"取数
SELECT *
FROM makt
INTO CORRESPONDING FIELDS OF TABLE t_tab
UP TO 10 ROWS.
"调用展示函数
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'MATNR' "表格要显示的字段
dynpprog = sy-repid "返回才程序
dynpnr = sy-dynnr "屏幕
dynprofield = 'P_MATNR' "往页面回填值的地方
value_org = 'S' "显示类型
TABLES
value_tab = t_tab. "传进去的表格 帮助的内表
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.
"展示表
DATA:BEGIN OF t_tab OCCURS 0,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
END OF t_tab.
"要使用F4的屏幕元素
PARAMETERS:p_matnr(20) TYPE c .
"监听F4 事件
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr.
PERFORM frm_help.
*&---------------------------------------------------------------------*
*& Form FRM_HELP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_help .
"取数
SELECT *
FROM makt
INTO CORRESPONDING FIELDS OF TABLE t_tab
UP TO 10 ROWS.
"调用展示函数
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'MATNR' "表格要显示的字段
dynpprog = sy-repid "返回才程序
dynpnr = sy-dynnr "屏幕
dynprofield = 'P_MATNR' "往页面回填值的地方
value_org = 'S' "显示类型
TABLES
value_tab = t_tab. "传进去的表格 帮助的内表
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.