行选择交互事件(AT LINE-SELECTION)是列表事件的一种,当用户双击write输出的报表行时,触发该事件。
例子:用write输出一个人员报表,双击某行,触发AT LINE-SELECTION事件,弹出人员详细信息。
例子程序代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
REPORT z_line_selection.
DATA: BEGIN OF git_main OCCURS 0,
number(10) TYPE c,
name(10) TYPE c,
END OF git_main.
DATA: BEGIN OF gwa_pop,
number(10) TYPE c,
name(10) TYPE c,
sex(2) TYPE c,
age TYPE i,
address(10) TYPE c,
END OF gwa_pop.
DATA: git_detail LIKE STANDARD TABLE OF gwa_pop WITH HEADER LINE.
AT LINE-SELECTION.
* 响应双击行
PERFORM frm_popup.
START-OF-SELECTION.
PERFORM frm_data_set.
* write输出
PERFORM frm_data_write.
*&---------------------------------------------------------------------*
*& Form FRM_POPUP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_popup .
* 弹出窗口
WINDOW STARTING AT 10 20 ENDING AT 50 25.
CASE sy-lisel.
WHEN '张三'.
READ TABLE git_detail WITH KEY number = '11001' INTO gwa_pop. "选定行的内容
WHEN '李四'.
READ TABLE git_detail WITH KEY number = '11002' INTO gwa_pop.
WHEN '王五'.
READ TABLE git_detail WITH KEY number = '11003' INTO gwa_pop.
ENDCASE.
IF gwa_pop IS NOT INITIAL.
WRITE:/ '编号:',gwa_pop-number.
WRITE:/ '姓名:',gwa_pop-name.
WRITE:/ '性别:',gwa_pop-sex.
WRITE:/ '年龄:',gwa_pop-age.
WRITE:/ '地址:',gwa_pop-address.
ENDIF.
ENDFORM. " FRM_POPUP
*&---------------------------------------------------------------------*
*& Form FRM_DATA_SET
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_data_set .
REFRESH: git_main,git_detail.
git_main-number = '11001'.
git_main-name = '张三'.
APPEND git_main.
git_main-number = '11002'.
git_main-name = '李四'.
APPEND git_main.
git_main-number = '11003'.
git_main-name = '王五'.
APPEND git_main.
git_detail-number = '11001'.
git_detail-name = '张三'.
git_detail-sex = '男'.
git_detail-age = '25'.
git_detail-address = '江苏苏州'.
APPEND git_detail.
git_detail-number = '11002'.
git_detail-name = '李四'.
git_detail-sex = '男'.
git_detail-age = '50'.
git_detail-address = '浙江杭州'.
APPEND git_detail.
git_detail-number = '11003'.
git_detail-name = '王五'.
git_detail-sex = '女'.
git_detail-age = '19'.
git_detail-address = '上海'.
APPEND git_detail.
ENDFORM. " FRM_DATA_SET
*&---------------------------------------------------------------------*
*& Form FRM_DATA_WRITE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_data_write .
LOOP AT git_main.
WRITE:/ git_main-name.
ENDLOOP.
ENDFORM. " FRM_DATA_WRITE
|
运行:
以上。