就是选择屏幕在PBO事件中需要使用到选择屏幕上某个字段的时候,直接用选择屏幕变量名是没办法获取到值的,因为系统只有在PAI中才会自动把值赋给选择屏幕的变量,这时候就可以使用函数DYNP_VALUES_READ来获取,同时也是适用于自定义的Dialog
DATA dynpfields TYPE TABLE OF dynpread WITH HEADER LINE.
* 获取屏幕上字段输入的值:此字段还没有更新到对应的内表或工作区中
dynpfields-fieldname = 'P_MTART'.
APPEND dynpfields.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-cprog
dynumb = sy-dynnr
TABLES
dynpfields = dynpfields
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
OTHERS = 11.
IF sy-subrc EQ 0.
READ TABLE dynpfields WITH KEY 'P_MTART'.
IF sy-subrc = 0.
p_mtart = dynpfields-fieldvalue.
TRANSLATE p_mtart TO UPPER CASE.
ENDIF.
ELSE.
* Implement suitable error handling here
ENDIF.