SAP允许直接通过ABAP代码在屏幕上创建一个页签,相关语法如下。
SELECTION-SCREEN BEGIN OF TABBED BLOCK <block> FOR n LINES.
每个页签都是由一个单独的子屏幕控制,N代表分页控件的高度,屏幕载入时必须先通过INITIALIZATION事件对其属性初始化。下例中将定义一个包含两个页签的TAB控件,代码所下所示。
1 REPORT ztest_sum. 2 3 TABLES:mara. 4 *TABLES sscrfields. "引用屏幕字段属性 5 6 SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN . "定义子屏幕100 7 SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001. 8 SELECT-OPTIONS:mat1 FOR mara-matnr NO INTERVALS. 9 SELECTION-SCREEN SKIP 1. 10 PARAMETERS: chk1 AS CHECKBOX DEFAULT 'X'. 11 SELECTION-SCREEN END OF BLOCK a1. 12 SELECTION-SCREEN END OF SCREEN 100. 13 14 SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN. 15 PARAMETERS:mat2 LIKE mara-matnr. 16 SELECTION-SCREEN END OF SCREEN 200. 17 18 *定义一个TAB空间,取名MYTAB,空间高为5,共分为两个页签BUTTON1/BUTTON2 19 *两个页签的功能代码分别为PUSH1/PUSH2 20 21 SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 5 LINES, 22 TAB (20) button1 USER-COMMAND push1, 23 TAB (20) button2 USER-COMMAND push2, 24 END OF BLOCK mytab. 25 26 *为TAB控件分别初始化值,应用于TEXT ELEMENT文本 27 INITIALIZATION. 28 button1 = text-010. 29 button2 = text-020. 30 mytab-prog = sy-repid. 31 mytab-dynnr = 100. 32 33 AT SELECTION-SCREEN. 34 CASE sy-ucomm. 35 WHEN 'PUSH1'. 36 mytab-dynnr = 100. 37 WHEN 'PUSH2'. 38 mytab-dynnr = 100. 39 WHEN OTHERS. 40 ENDCASE.
执行结果如下