(1)在屏幕编辑器的layout中,指定屏幕元素所使用的search help
(2)使用函数的方法,在选择屏幕上实现F4.
所使用的函数为:F4IF_INT_TABLE_VALUE_REQUEST
REPORT ZTEST03.
types : begin of t_s_werks,
werks type t001w-werks,
name1 type t001w-name1,
name2 type t001w-name2,
stras type t001w-stras,
ort01 type t001w-ort01,
end of t_s_werks .
types : t_i_werks type standard table of t_s_werks .
data : l_it_werks type t_i_werks.
parameters : p_werks(4) type c .
at selection-screen on VALUE-REQUEST FOR p_werks .
SELECT WERKS "
NAME1 "
NAME2 " 2
STRAS "/-
ORT01 "
FROM T001W
INTO CORRESPONDING FIELDS OF TABLE L_IT_WERKS.
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'WERKS' "返回的表中的字段值,一定要是大写
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_WERKS' "填充的是屏幕上的哪个字段
value_org = 'S' "Cell by cell
tables
value_tab = L_IT_WERKS "F4中要显示的值,放到这个内表中
exceptions
parameter_error = 1
no_value_found = 2
others = 3.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
types : begin of t_s_werks,
werks type t001w-werks,
name1 type t001w-name1,
name2 type t001w-name2,
stras type t001w-stras,
ort01 type t001w-ort01,
end of t_s_werks .
types : t_i_werks type standard table of t_s_werks .
data : l_it_werks type t_i_werks.
parameters : p_werks(4) type c .
at selection-screen on VALUE-REQUEST FOR p_werks .
SELECT WERKS "
NAME1 "
NAME2 " 2
STRAS "/-
ORT01 "
FROM T001W
INTO CORRESPONDING FIELDS OF TABLE L_IT_WERKS.
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'WERKS' "返回的表中的字段值,一定要是大写
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_WERKS' "填充的是屏幕上的哪个字段
value_org = 'S' "Cell by cell
tables
value_tab = L_IT_WERKS "F4中要显示的值,放到这个内表中
exceptions
parameter_error = 1
no_value_found = 2
others = 3.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.