模拟Select-Options对象实现多项数据输入功能
Posted 独吊东南枝
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了模拟Select-Options对象实现多项数据输入功能相关的知识,希望对你有一定的参考价值。
*COMPLEX_SELECTIONS_DIALOG:开启输入多值对话框
TYPE-POOLS:icon."按钮上显示图标时需要调用该类库
DATA:l_count TYPE i."用于计算内表数值总数
DATA:lmail(50) TYPE c."定义mail地址输入变量长度及类型
*定义屏幕元素及文本元素
SELECTION-SCREEN:BEGIN OF BLOCK alv WITH FRAME TITLE text-002.
SELECTION-SCREEN:BEGIN OF LINE.
SELECTION-SCREEN:comment (14) text-001.
PARAMETERS:mailcopy LIKE lmail.
SELECTION-SCREEN:PUSHBUTTON 63(5) pubu USER-COMMAND mailbutt.
SELECTION-SCREEN:END OF LINE.
SELECTION-SCREEN:END OF BLOCK alv.
DATA:mailtype TYPE c VALUE ‘‘.
*定义一隐藏的SELECT-OPTIONS用于保存输入值
SELECT-OPTIONS:mailadd FOR lmail NO-DISPLAY.
AT SELECTION-SCREEN OUTPUT.
CLEAR l_count.
DESCRIBE TABLE mailadd LINES l_count.
*判断内表是否有值来设置按钮图标
IF l_count > 1.
WRITE icon_display_more AS ICON TO pubu.
ELSE.
WRITE icon_enter_more AS ICON TO pubu.
ENDIF.
AT SELECTION-SCREEN.
CLEAR l_count.
DESCRIBE TABLE mailadd LINES l_count.
*实现内表与文本元素间的值传递
IF NOT mailcopy IS INITIAL AND mailadd[] IS INITIAL.
mailadd-low = mailcopy.
APPEND mailadd.
ENDIF.
IF l_count = 1.
REFRESH mailadd.
CLEAR mailadd.
IF NOT mailcopy IS INITIAL.
mailadd-low = mailcopy.
APPEND mailadd.
ENDIF.
ENDIF.
IF l_count > 1.
IF mailcopy IS INITIAL.
DELETE mailadd INDEX 1.
ELSE.
mailadd-low = mailcopy.
MODIFY mailadd INDEX 1 TRANSPORTING low.
ENDIF.
ENDIF.
*在单击按钮的事件时调用输入多值输入对话框
IF sy-ucomm = ‘MAILBUTT‘.
PERFORM show_box.
ENDIF.
*调用多值输入对话框
FORM show_box.
TYPE-POOLS aqadh.
DATA:tab_and_field TYPE rstabfield.
tab_and_field-tablename = ‘ADR6‘.
tab_and_field-fieldname = ‘SMTP_ADDR‘.
*该函数将输入值传递给内表
CALL FUNCTION ‘COMPLEX_SELECTIONS_DIALOG‘
EXPORTING
text = ‘SET E-Mail To‘
tab_and_field = tab_and_field
TABLES
range = mailadd[]
EXCEPTIONS
no_range_tab = 1
cancelled = 2
internal_error = 3
OTHERS = 4.
*将内表首行值传给文本对象,显示在屏幕上
IF NOT mailadd[] IS INITIAL.
READ TABLE mailadd INDEX 1.
mailcopy = mailadd