实现效果
未加搜索帮助出口的效果
加了搜索帮助出口的效果
问题原因
通过T-CODE SE11我们首先参考数据库表中的元素实现了搜索帮助,但是由于参考的元素不是主键,所以会有重复项,这里就需要通过搜索帮助出口实现去重的功能。
实现步骤
3.1参考SAP的预定义函数F4IF_SHLP_EXIT_EXAMPLE创建函数ZPP_F4IF_EXIT_ZPPR043,参数也都参考F4IF_SHLP_EXIT_EXAMPLE
FUNCTION zpp_f4if_exit_zppr043.
*"----------------------------------------------------------------------
*"*"本地接口:
*" TABLES
*" SHLP_TAB TYPE SHLP_DESCT
*" RECORD_TAB STRUCTURE SEAHLPRES
*" CHANGING
*" REFERENCE(SHLP) TYPE SHLP_DESCR
*" REFERENCE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL
*"----------------------------------------------------------------------
RANGES: ra_zzbbh FOR zppt007-zzbbh,
ra_zsegment FOR zppt007-zsegment,
ra_uname FOR zppt007-uname,
ra_datum FOR zppt007-datum.
DATA:BEGIN OF gs_sel_zzbbh,
zzbbh LIKE zppt007-zzbbh,
zsegment LIKE zppt007-zsegment,
uname LIKE zppt007-uname,
datum LIKE zppt007-datum,
END OF gs_sel_zzbbh,
gt_sel_zzbbh LIKE TABLE OF gs_sel_zzbbh.
CHECK callcontrol-step = 'SELECT'.
LOOP AT shlp-selopt INTO DATA(ls_selopt).
CASE ls_selopt-shlpfield.
WHEN 'ZZBBH'.
ra_zzbbh = CORRESPONDING #( ls_selopt ).
APPEND ra_zzbbh.
WHEN 'ZSEGMENT'.
ra_zsegment = CORRESPONDING #( ls_selopt ).
APPEND ra_zsegment.
WHEN 'UNAME'.
ra_uname = CORRESPONDING #( ls_selopt ).
APPEND ra_uname.
WHEN 'DATUM'.
ra_datum = CORRESPONDING #( ls_selopt ).
APPEND ra_datum.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
*根据输入参数查询数据
CLEAR:gt_sel_zzbbh.
SELECT
zzbbh zsegment uname datum
INTO TABLE gt_sel_zzbbh
FROM zppt007
WHERE zzbbh IN ra_zzbbh AND zsegment IN ra_zsegment AND uname IN ra_uname AND datum IN ra_datum.
SORT gt_sel_zzbbh BY zzbbh zsegment uname datum.
DELETE ADJACENT DUPLICATES FROM gt_sel_zzbbh COMPARING zzbbh zsegment uname datum.
*将查询结果回执到屏幕上来
CALL FUNCTION 'F4UT_RESULTS_MAP'
TABLES
shlp_tab = shlp_tab
record_tab = record_tab
source_tab = gt_sel_zzbbh
CHANGING
shlp = shlp
callcontrol = callcontrol
EXCEPTIONS
illegal_structure = 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.
*下一个时间点直接转到DISP,否则无法再屏幕上显示帮助列表
callcontrol-step = 'DISP'.
ENDFUNCTION.