效果:
代码:
*&--------------------------------------------------------------------* *& REPORT ZPPRTEST *&--------------------------------------------------------------------* *& *&--------------------------------------------------------------------* REPORT ZPPRTEST. SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN. PARAMETERS: p_werks LIKE marc-werks DEFAULT '2000' OBLIGATORY. SELECTION-SCREEN END OF SCREEN 100. SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN. PARAMETERS: p_matnr LIKE marc-matnr. SELECTION-SCREEN END OF SCREEN 200. "定义一个TAB空间, 取名为MYTAB, 控件高10行, 共分为二个页签. SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 10 LINES, TAB (25) button1 USER-COMMAND push1, TAB (25) button2 USER-COMMAND push2, END OF BLOCK mytab. ************************************************************************ * INITIALIZATION ************************************************************************ INITIALIZATION. "为TAB控件分配初始化值 PERFORM tab_initial. ************************************************************************ * AT SELECTION SCREEN ************************************************************************ AT SELECTION-SCREEN. "为控件页签单击事件, 选择不同页签显示不同子屏幕. PERFORM tab_change. ************************************************************************ * AT SELECTION SCREEN OUTPUT ************************************************************************ AT SELECTION-SCREEN OUTPUT. ************************************************************************ * REPORT FORMAT ************************************************************************ TOP-OF-PAGE. END-OF-PAGE. ************************************************************************ * MAIN PROCESS ************************************************************************ START-OF-SELECTION. "根据不同的选项卡执行不同的FORM CASE mytab-dynnr. WHEN '100'. WRITE 1. * PERFORM get_data. * PERFORM display_data. WHEN '200'. WRITE 2. * PERFORM get_data2. * PERFORM display_data2. ENDCASE. END-OF-SELECTION. FORM tab_initial. button1 = TEXT-010. button2 = TEXT-020. mytab-prog = sy-repid. "取内存记录的mytab-dynnr IMPORT mytab-dynnr TO mytab-dynnr FROM MEMORY ID 'TAB'. IF mytab-dynnr IS INITIAL. mytab-dynnr = 100. mytab-activetab = 'PUSH1'. ELSE. CASE mytab-dynnr. WHEN 100. mytab-dynnr = 100. mytab-activetab = 'PUSH1'. WHEN 200. mytab-dynnr = 200. mytab-activetab = 'PUSH2'. ENDCASE. ENDIF. ENDFORM. FORM tab_change. CASE sy-ucomm. WHEN 'ONLI'. "用内存记录的mytab-dynnr EXPORT mytab-dynnr FROM mytab-dynnr TO MEMORY ID 'TAB'. WHEN 'PUSH1'. mytab-dynnr = 100. mytab-activetab = 'BUTTON1'. WHEN 'PUSH2'. mytab-dynnr = 200. mytab-activetab = 'BUTTON2'. ENDCASE. ENDFORM.