屏幕上创建页签

tab效果在很多地方都有出现,很多时候方便用户操作,SAP也提供同样的功能,特别是在屏幕开发时,经常用到,这里做下笔记,整个简单的tab页签。

语法:

SELECTION-SCREEN BEGIN OF TABBED BLOCK <b> FOR n LINES.

1.选择屏幕,一个页面单独一个子屏幕:

 1 TABLES: sscrfields,mara.
 2 
 3 * sub screen 100.
 4 SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
 5 SELECTION-SCREEN BEGIN OF BLOCK 110 WITH FRAME TITLE mytitle2.
 6 SELECT-OPTIONS: mat1 FOR mara-matnr NO INTERVALS.
 7 SELECTION-SCREEN SKIP 1.
 8 SELECTION-SCREEN END OF BLOCK 110.
 9 SELECTION-SCREEN END OF SCREEN 100.
10 
11 * sub screen 200.
12 SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
13 SELECT-OPTIONS: mat2 FOR mara-matnr.
14 SELECTION-SCREEN END OF SCREEN 200.
15 
16 * tab
17 SELECTION-SCREEN:BEGIN OF TABBED BLOCK mytab FOR 5 LINES,
18                  TAB (20) button1 USER-COMMAND push1,
19                  TAB (20) button2 USER-COMMAND push2,
20 END OF BLOCK mytab.

这里定义了2个子屏幕:100 ,200.

2.在 INITIALIZATION 事件中分配初始值:

1 INITIALIZATION.
2   mytitle2 = 'Tab Op.'.
3   mytab = 'Tab'.
4   button1 = 'tab1'.
5   button2 = 'tab2'.
6   mytab-prog = sy-repid.
7   mytab-dynnr = 100. 

3.添加Tab单击页签时触发的事件:

1 AT SELECTION-SCREEN.
2   CASE sy-ucomm.
3     WHEN 'PUSH1'.
4       mytab-dynnr = 100.
5       mytab-activetab = 'button1'.
6     WHEN 'PUSH2'.
7       mytab-dynnr = 200.
8       mytab-activetab = 'button2'.
9   ENDCASE.

到这里,tab页签效果就出来了:

完整代码:

 1 *&---------------------------------------------------------------------*
 2 *& Report  ZABAPX_SSCR
 3 *&
 4 *&---------------------------------------------------------------------*
 5 *&
 6 *&
 7 *&---------------------------------------------------------------------*
 8 
 9 REPORT  zabapx_sscr.
10 TABLES: sscrfields,mara.
11 
12 * sub screen 100.
13 SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
14 SELECTION-SCREEN BEGIN OF BLOCK 110 WITH FRAME TITLE mytitle2.
15 SELECT-OPTIONS: mat1 FOR mara-matnr NO INTERVALS.
16 SELECTION-SCREEN SKIP 1.
17 SELECTION-SCREEN END OF BLOCK 110.
18 SELECTION-SCREEN END OF SCREEN 100.
19 
20 * sub screen 200.
21 SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
22 SELECT-OPTIONS: mat2 FOR mara-matnr.
23 SELECTION-SCREEN END OF SCREEN 200.
24 
25 * tab
26 SELECTION-SCREEN:BEGIN OF TABBED BLOCK mytab FOR 5 LINES,
27                  TAB (20) button1 USER-COMMAND push1,
28                  TAB (20) button2 USER-COMMAND push2,
29 END OF BLOCK mytab.
30 
31 INITIALIZATION.
32   mytitle2 = 'Tab Op.'.
33   mytab = 'Tab'.
34   button1 = 'tab1'.
35   button2 = 'tab2'.
36 
37   mytab-prog = sy-repid.
38   mytab-dynnr = 100.
39 
40 AT SELECTION-SCREEN.
41   CASE sy-ucomm.
42     WHEN 'PUSH1'.
43       mytab-dynnr = 100.
44       mytab-activetab = 'button1'.
45     WHEN 'PUSH2'.
46       mytab-dynnr = 200.
47       mytab-activetab = 'button2'.
48   ENDCASE.
posted @ 2012-11-08 16:11  沙茶叶  阅读(709)  评论(0编辑  收藏  举报