要实现如下一个功能,在选择屏幕中,“订单类型”要来自 likp 的 lfart 字段和 vbak 的 auart 的内容。
*交货类型搜索帮助
DATA: BEGIN OF gwa_sorthelp OCCURS 0,
sorthelp LIKE likp-lfart,
END OF gwa_sorthelp.
DATA: gt_sorthelp LIKE TABLE OF gwa_sorthelp .
DATA: igt_sorthelp LIKE gwa_sorthelp OCCURS 0,
iwa_sorthelp LIKE gwa_sorthelp.
DATA: BEGIN OF gwa_vbaksorthelp OCCURS 0,
sorthelp LIKE vbak-auart,
END OF gwa_vbaksorthelp.
DATA:gt_vbaksorthelp LIKE TABLE OF gwa_vbaksorthelp .
DATA: igt_vbaksorthelp LIKE gwa_vbaksorthelp OCCURS 0,
iwa_vbaksorthelp LIKE gwa_vbaksorthelp.
*选择屏幕定义
PARAMETERS: sorthelp LIKE gwa_sorthelp-sorthelp.
*点击事件
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sorthelp.
PERFORM frm_get_sorthelp.
*实现搜索帮助
FORM frm_get_sorthelp.
*查询数据
SELECT lfart INTO TABLE gt_sorthelp FROM likp.
SELECT auart INTO TABLE gt_vbaksorthelp FROM vbak.
*格式化数据
LOOP AT gt_sorthelp INTO gwa_sorthelp.
CLEAR iwa_sorthelp.
iwa_sorthelp-sorthelp = gwa_sorthelp-sorthelp.
COLLECT iwa_sorthelp INTO igt_sorthelp.
ENDLOOP.
LOOP AT gt_vbaksorthelp INTO gwa_vbaksorthelp.
CLEAR iwa_vbaksorthelp.
iwa_vbaksorthelp-sorthelp = gwa_vbaksorthelp-sorthelp.
COLLECT iwa_vbaksorthelp INTO igt_vbaksorthelp.
ENDLOOP.
LOOP AT igt_vbaksorthelp INTO iwa_vbaksorthelp.
iwa_sorthelp-sorthelp = iwa_vbaksorthelp-sorthelp.
APPEND iwa_sorthelp TO igt_sorthelp.
ENDLOOP.
*弹出选择框
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
dynpprog = 'ZGNSDR007'
retfield = 'SORTHELP' "预选值要填入的字段名
dynpnr = sy-dynnr
dynprofield = 'SORTHELP' " 此屏幕字段参数
value_org = 'S'
TABLES
value_tab = igt_sorthelp[] " 存放预选值清单的内表
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
ENDFORM.