ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ABAP中如何使用listbox

ABAP中如何使用listbox

原创 Linux操作系统 作者:chouer523 时间:2019-07-18 21:33:01 0 删除 编辑
*******************************************
**原创文章,版权所有,转载请保留信息
**msn:njchouer@hotmail.com
**作者:chouer
*******************************************

*&---------------------------------------------------------------------*
*& Report Ztest
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT Ztest.

TYPE-POOLS: VRM. "存放combobox内容的type pool

DATA: NAME TYPE VRM_ID, "list box的名称

LIST TYPE VRM_VALUES, "list box的值

VALUE LIKE LINE OF LIST."list box的结构

*定义checkbox,指定command,为了能够响应选择屏幕中值的改变

PARAMETERS: P_CB1 TYPE C AS CHECKBOX DEFAULT 'X' USER-COMMAND CHECK,

P_CB2 TYPE C AS CHECKBOX DEFAULT 'X' USER-COMMAND CHECK.

*定义listbox,必须指定visible length

PARAMETERS: P_LIST1(10) TYPE C AS LISTBOX

VISIBLE LENGTH 15 ,

P_LIST2(20) TYPE C AS LISTBOX

VISIBLE LENGTH 25 .

*开始执行

AT SELECTION-SCREEN OUTPUT .

*选择1而没有选择2

IF P_CB1 = 'X' AND P_CB2 = ''.

*向listbox里面添加值

REFRESH LIST .

VALUE-KEY = '1111111111' . "这个就是变量P_LIST的值

VALUE-TEXT = '1111111111' . "这个是text

APPEND VALUE TO LIST .

VALUE-KEY = '2222222222' .

VALUE-TEXT = '2222222222' .

APPEND VALUE TO LIST .

VALUE-KEY = '3333333333' .

VALUE-TEXT = '3333333333' .

APPEND VALUE TO LIST .

*调用函数显示listbox里面的值

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = 'P_LIST1'

VALUES = LIST.

*把第二个listbox的值清空,并且不能输入

CLEAR P_LIST2 .

LOOP AT SCREEN .

IF SCREEN-NAME = 'P_LIST2' .

SCREEN-INPUT = 0 .

MODIFY SCREEN .

ENDIF .

ENDLOOP .

*选择2,没有选择1,同上

ELSEIF P_CB2 = 'X' AND P_CB1 = ''.

REFRESH LIST .

VALUE-KEY = 'AAAAAAAAAAAAAAAAAAAA' .

VALUE-TEXT = 'AAAAAAAAAAAAAAAAAAAA' .

APPEND VALUE TO LIST .

VALUE-KEY = 'BBBBBBBBBBBBBBBBBBBB' .

VALUE-TEXT = 'BBBBBBBBBBBBBBBBBBBB' .

APPEND VALUE TO LIST .

VALUE-KEY = 'CCCCCCCCCCCCCCCCCCCC' .

VALUE-TEXT = 'CCCCCCCCCCCCCCCCCCCC' .

APPEND VALUE TO LIST .

APPEND VALUE TO LIST .

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = 'P_LIST2'

VALUES = LIST.

*清空listbox 1的值

CLEAR P_LIST1 .

LOOP AT SCREEN .

IF SCREEN-NAME = 'P_LIST1' .

SCREEN-INPUT = 0 .

MODIFY SCREEN .

ENDIF .

ENDLOOP .

*都没有选择,都清空且不能输入

ELSEIF P_CB1 = '' AND P_CB2 = '' .

CLEAR: P_LIST1,P_LIST2 .

LOOP AT SCREEN .

IF SCREEN-NAME = 'P_LIST1' .

SCREEN-INPUT = 0 .

MODIFY SCREEN .

ENDIF .

ENDLOOP .

LOOP AT SCREEN .

IF SCREEN-NAME = 'P_LIST2' .

SCREEN-INPUT = 0 .

MODIFY SCREEN .

ENDIF .

ENDLOOP .

*都选,执行

ELSEIF P_CB1 = 'X' AND P_CB2 = 'X' .

REFRESH LIST .

VALUE-KEY = '1111111111' .

VALUE-TEXT = '1111111111' .

APPEND VALUE TO LIST .

VALUE-KEY = '2222222222' .

VALUE-TEXT = '2222222222' .

APPEND VALUE TO LIST .

VALUE-KEY = '3333333333' .

VALUE-TEXT = '3333333333' .

APPEND VALUE TO LIST .

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = 'P_LIST1'

VALUES = LIST.

REFRESH LIST .

VALUE-KEY = 'AAAAAAAAAAAAAAAAAAAA' .

VALUE-TEXT = 'AAAAAAAAAAAAAAAAAAAA' .

APPEND VALUE TO LIST .

VALUE-KEY = 'BBBBBBBBBBBBBBBBBBBB' .

VALUE-TEXT = 'BBBBBBBBBBBBBBBBBBBB' .

APPEND VALUE TO LIST .

VALUE-KEY = 'CCCCCCCCCCCCCCCCCCCC' .

VALUE-TEXT = 'CCCCCCCCCCCCCCCCCCCC' .

APPEND VALUE TO LIST .

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = 'P_LIST2'

VALUES = LIST.

ENDIF .

START-OF-SELECTION .

*输出到第二屏幕看看

WRITE: P_LIST1 ,/ P_LIST2 .

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/332542/viewspace-53546/,如需转载,请注明出处,否则将追究法律责任。

下一篇: SAP 术语表
请登录后发表评论 登录
全部评论

注册时间:2019-03-28

  • 博文量
    74
  • 访问量
    47769