项目中,经常用到,点击按钮时弹出一个对话框,选择一些值,然后返回选择的值,进一步操作,下面是使用弹窗对话框函数POPUP_GET_VALUES返回日期的例子,当然后也可以时其他类型的,定义数据元素时,根据需要定义成相应的类型就行了,效果如下图:
代码如下:
DATA: it_value TYPE TABLE OF sval,
wa_value TYPE sval,
lv_rtn_cd.
CLEAR:it_value,wa_value,lv_rtn_cd.
IF lv_cmd = '1' OR lv_cmd = '2'.
wa_value-tabname = 'ZMMDATE'.
wa_value-fieldname = 'BDATE'.
wa_value-value = sy-datum.
APPEND wa_value TO it_value.
wa_value-tabname = 'ZMMDATE'.
wa_value-fieldname = 'EDATE'.
wa_value-value = sy-datum.
APPEND wa_value TO it_value.
ELSE.
wa_value-tabname = 'ZMMDATE'.
wa_value-fieldname = 'JDATE'.
wa_value-value = sy-datum.
APPEND wa_value TO it_value.
ENDIF.
CALL FUNCTION 'POPUP_GET_VALUES'
EXPORTING
popup_title = '日期选择'
IMPORTING
returncode = lv_rtn_cd
TABLES
fields = it_value.
DATA:gt_itab TYPE TABLE OF zputwbsrq_s WITH HEADER LINE.
DATA:msg TYPE TABLE OF zbapimessage WITH HEADER LINE.
DATA:gt_in TYPE TABLE OF zputprrq_s WITH HEADER LINE.
DATA:gt_in1 TYPE TABLE OF zputporq_s WITH HEADER LINE.
DATA:msg1 TYPE TABLE OF zbapiret WITH HEADER LINE.
DATA:gt_in2 TYPE TABLE OF zputplrq_s WITH HEADER LINE.
IF lv_rtn_cd IS INITIAL.
READ TABLE it_value INTO wa_value WITH KEY fieldname = 'BDATE'.
IF sy-subrc = 0.
gt_itab-p_day = wa_value-value.
gt_itab-b_day = wa_value-value.
ENDIF.
ENDIF.