在某项目中,需要用Search Help类似的功能弹出工厂信息,然后回填到字段中,在输入工厂时要根据输入的值来弹出某一个工厂,在PROCESS ON VALUE-REQUEST事件中捕捉不到屏幕的值,为了解决此问题,可以通过Call 一个Function来动态取到屏幕的值,代码如下:
DATA: wls_return TYPE ddshretval,
wlt_return LIKE TABLE OF wls_return.
data: it_dynpfields TYPE STANDARD TABLE OF dynpread,
wa_dynpfields TYPE dynpread.
CLEAR ws_t012.
REFRESH wt_t012.
CLEAR wa_dynpfields.
CLEAR it_dynpfields.
*解决屏幕输入时捕捉不到值的问题
**取公司代码屏幕字段的输入值
wa_dynpfields-fieldname = ‘P_BUKRS’.
APPEND wa_dynpfields TO it_dynpfields.
CALL FUNCTION ‘DYNP_VALUES_READ’
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = it_dynpfields.
READ TABLE it_dynpfields WITH KEY fieldname = ‘P_BUKRS’ INTO wa_dynpfields.
IF NOT wa_dynpfields-fieldvalue IS INITIAL.
P_BUKRS = wa_dynpfields-fieldvalue. “得到屏幕录入的值
ENDIF.
IF p_bukrs1 NE space.
CONCATENATE ‘%’ p_bukrs1 INTO p_bukrs1.
select zbukrs zbanktxt
into corresponding fields of table wt_bukrs
from zbank where BUKRS = P_BUKRS AND zbukrs like p_bukrs1.
ELSE.
select zbukrs zbanktxt
into corresponding fields of table wt_t012
FROM ZBANK WHERE BUKRS = P_BUKRS.
ENDIF.
CALL FUNCTION ‘F4IF_INT_TABLE_VALUE_REQUEST’
EXPORTING
retfield = ‘zbukrs’
value_org = ‘S’
TABLES
value_tab = wt_t012
return_tab = wlt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
READ TABLE wlt_return INDEX 1 INTO wls_return.
IF sy-subrc EQ 0.
p_bukrs1 = wls_return-fieldval.
ENDIF.