效果图:
demo代码
需要特别注意的是abap memory的应用
文本版:
*&---------------------------------------------------------------------*
*& Report ZLM_SCREEN3
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zlm_screen3.
TABLES:mara.
SELECTION-SCREEN BEGIN OF SCREEN 0100 AS SUBSCREEN .
PARAMETERS:
p_dwms TYPE char1 AS LISTBOX VISIBLE LENGTH 30,
p_dwm TYPE string NO-DISPLAY.
SELECT-OPTIONS:
s_matnr FOR mara-matnr .
SELECTION-SCREEN END OF SCREEN 0100.
SELECTION-SCREEN BEGIN OF SCREEN 0300 AS SUBSCREEN.
PARAMETERS: rb_down RADIOBUTTON GROUP rad1, "下载模版
rb_up RADIOBUTTON GROUP rad1, "导入数据
p_file LIKE rlgrap-filename. "文件路径
SELECTION-SCREEN END OF SCREEN 0300.
SELECTION-SCREEN BEGIN OF TABBED BLOCK mytab FOR 4 LINES."子屏幕的行数
SELECTION-SCREEN TAB (6) text1 USER-COMMAND but1.
SELECTION-SCREEN TAB (10) text2 USER-COMMAND but2.
SELECTION-SCREEN END OF BLOCK mytab.
*----------------------------------------------------------------------*
* INITIALIZATION
*----------------------------------------------------------------------*
INITIALIZATION . "给标签赋值
PERFORM frm_init.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN.
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
CASE sy-dynnr.
WHEN 1000.
CASE sy-ucomm.
WHEN 'BUT1'. " 'BUT1'
mytab-dynnr = 0100.
WHEN 'BUT2'. " 'BUT2'
mytab-dynnr = 0300.
WHEN OTHERS.
ENDCASE.
ENDCASE.
*----------------------------------------------------------------------*
* 事件处理
*----------------------------------------------------------------------*
START-OF-SELECTION.
CASE mytab-dynnr.
WHEN 0100.
MESSAGE '1' TYPE 'I'.
WHEN 0300. "300屏幕的操作
DATA: lv_subscreen TYPE string .
"ABAP memory是为了能控制返回时返回到哪个页签
lv_subscreen = '0300'.
EXPORT lv_subscreen TO MEMORY ID 'M1'.
MESSAGE '2' TYPE 'I'.
ENDCASE.
FORM frm_init .
DATA: lv_subscreen TYPE string .
text1 = '页签一'.
text2 = '页签二'.
IMPORT lv_subscreen FROM MEMORY ID 'M1' . "读取内存,获取当前处理页签
DATA(v_dynnr) = lv_subscreen.
mytab-prog = sy-repid.
IF v_dynnr = space.
mytab-dynnr = 0100.
mytab-activetab = 'BUT1'. " 'BUT1'
ELSE.
mytab-dynnr = v_dynnr.
IF v_dynnr = 0300 .
mytab-activetab = 'BUT2'. "'BUT2'
ENDIF.
ENDIF.
ENDFORM. " FRM_INIT