我们通过调用内置函数POPUP_GET_VALUES
来实现弹框数据某些对应的数据内容. 具体参数以及语法如下.
CALL FUNCTION 'POPUP_GET_VALUES'
EXPORTING
* NO_VALUE_CHECK = ' '
popup_title = '物料商品选择'
* START_COLUMN = '5'
* START_ROW = '5'
IMPORTING
returncode = lv_rtn_cd
TABLES
fields = it_value
EXCEPTIONS
error_in_fields = 1
OTHERS = 2.
IF sy-subrc = 0.
LV_STGRD = it_value[ 1 ]-value .
LV_BUDAT = it_value[ 2 ]-value .
LV_MONAT = it_value[ 3 ]-value .
ENDIF .
popup_title :弹窗的标题
fields 表中存储要和用户交互的字段,
每个字段有三个参数分别是tabname:参考表;fieldname:字段名称;value:默认值。
要求字段名称必须是参考表中的数据,会自动带出搜索帮助。
START_COLUMN和START_ROW 是弹窗位置
实际案例
*数据准备
DATA LV_STGRD TYPE RF05R-STGRD .
DATA LV_BUDAT TYPE RF05R-BUDAT .
DATA LV_MONAT TYPE RF05R-MONAT .
DATA: it_value TYPE TABLE OF sval,
wa_value TYPE sval,
lv_rtn_cd.
*操作数据
wa_value-tabname = 'BKPF'.
wa_value-fieldname = 'STGRD'.
wa_value-value = '01'.
APPEND wa_value TO it_value.
wa_value-tabname = 'BKPF '.
wa_value-fieldname = 'BUDAT'.
wa_value-value = sy-datum .
APPEND wa_value TO it_value.
wa_value-tabname = 'BKPF'.
wa_value-fieldname = 'MONAT'.
wa_value-value = sy-datum+4(2).
APPEND wa_value TO it_value.
*调用函数
CALL FUNCTION 'POPUP_GET_VALUES'
EXPORTING
* NO_VALUE_CHECK = ' '
popup_title = '冲销数据'
* START_COLUMN = '5'
* START_ROW = '5'
IMPORTING
returncode = lv_rtn_cd
TABLES
fields = it_value
EXCEPTIONS
error_in_fields = 1
OTHERS = 2.
IF sy-subrc = 0.
LV_STGRD = it_value[ 1 ]-value .
LV_BUDAT = it_value[ 2 ]-value .
LV_MONAT = it_value[ 3 ]-value .
ENDIF .
WRITE : LV_BUDAT .