FM实现F4帮助系列三:弹出框多筛选条件的搜索帮助(根据搜索帮助筛选字段)
函数:F4IF_GET_SHLP_DESCR
F4IF_START_VALUE_REQUEST
效果图:
本例子代码:
找到需要的帮助:
*&---------------------------------------------------------------------*
*& Report ZLM_TEST_045
REPORT zlm_test_045.
TABLES makt.
DATA:
BEGIN OF str_f4,
matnr TYPE matnr,
maktx TYPE maktx,
END OF str_f4.
DATA:l_it_f4 LIKE TABLE OF str_f4.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
SELECT-OPTIONS:
s_matnr FOR makt-matnr NO INTERVALS.
SELECTION-SCREEN END OF BLOCK b1.
"帮助
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_matnr-low.
SELECT * FROM makt INTO CORRESPONDING FIELDS OF TABLE l_it_f4.
PERFORM frm_f4." USING 'S_MATNR-LOW' .
*&-------------------------------------------------------------------
*& 搜索帮助
*&-------------------------------------------------------------------
FORM frm_f4.
DATA g_shlp_descr_t TYPE shlp_descr_t.
DATA gwa_shlp_descr_t_interface TYPE ddshiface.
DATA: gt_return_tab TYPE TABLE OF ddshretval WITH HEADER LINE.
"调用标准帮助
CALL FUNCTION 'F4IF_GET_SHLP_DESCR'
EXPORTING
shlpname = 'MAT1W'
shlptype = 'SH'
IMPORTING
shlp = g_shlp_descr_t.
LOOP AT g_shlp_descr_t-interface INTO gwa_shlp_descr_t_interface.
IF gwa_shlp_descr_t_interface = 'MATNR'.
gwa_shlp_descr_t_interface-valfield = 'X'.
MODIFY g_shlp_descr_t-interface FROM gwa_shlp_descr_t_interface.
ENDIF.
ENDLOOP.
CALL FUNCTION 'F4IF_START_VALUE_REQUEST'
EXPORTING
shlp = g_shlp_descr_t
maxrecords = 500
multisel = 'X'
TABLES
return_values = gt_return_tab.
"获取选中值 可以多选 拥有select options
LOOP AT gt_return_tab.
s_matnr-sign = 'I'.
s_matnr-option = 'EQ'.
s_matnr-low = gt_return_tab-fieldval.
APPEND s_matnr.
ENDLOOP.
ENDFORM. " FRM_F4
另外一个F4增强的例子,也是添加筛选字段:
http://blog.sina.com.cn/s/blog_c0978c9b0101h1qf.html