SAP允许直接通过ABAP代码在屏幕上创建一个页签,相关语法如下:
SELECTION-SCREEN BEGIN OF TABBED BLOCK
每个页签都是由一个单独的子屏幕控制,n代表分页控件的调试,屏幕载入时必须先通过INITIALIZATION事件对其属性初始化。下例中将定义 一个包含两个页签 的TAB控件,代码如下所示:
TABLES:MARA.
*定义子屏幕100
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:MAT1 FOR MARA-MATNR NO INTERVALS.
SELECTION-SCREEN SKIP 1.
PARAMETERS: CHK1 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK A1.
SELECTION-SCREEN END OF SCREEN 100.
*定义子屏幕200
SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK A2 WITH FRAME TITLE TEXT-001.
PARAMETERS: MAT2 LIKE MARA-MATNR.
SELECTION-SCREEN END OF BLOCK A2.
SELECTION-SCREEN END OF SCREEN 200.
*定义一个TAB空间,取名为:MYTAB,控件高为5,共分两个页签:BUTTON1,BUTTON2
*两个页签的功能代码分别为:PUSH1,PUSH2
SELECTION-SCREEN: BEGIN OF TABBED BLOCK MYTAB FOR 5 LINES,
TAB (20) BUTTON1 USER-COMMAND PUSH1,
TAB (20) BUTTON2 USER-COMMAND PUSH2,
END OF BLOCK MYTAB.
*为TAB控件分配初始化值,应用TEXT ELEMENT 定义文本
INITIALIZATION.
BUTTON1 = TEXT-010.
BUTTON2 = TEXT-020.
MYTAB-PROG = SY-REPID.
MYTAB-DYNNR = 100.
*TAB控件页签单击事件,选择不同页签显示不同子屏幕
AT SELECTION-SCREEN.
CASE SY-UCOMM.
WHEN 'PUSH1'.
MYTAB-DYNNR = 100.
MYTAB-ACTIVETAB = 'BUTTON1'.
WHEN 'PUSH2'.
MYTAB-DYNNR = 200.
MYTAB-ACTIVETAB = 'BUTTON2'.
ENDCASE.