1、背景:最近在看sap的一些abapDemo,看了一个比较好用的功能,分享一下,希望对用到的兄弟有帮助,主要功能是:在选择屏幕上弹出一个小窗口,放一些按钮在上面,触发不同按钮,会处理不同事务,如下图所示:
2、代码如下:
REPORT ZTEST_SEL_SCREEN_PUSHBUTTON.
TABLES SSCRFIELDS.
DATA FLAG(1) TYPE C.
SELECTION-SCREEN:
BEGIN OF SCREEN 500 AS WINDOW TITLE TIT,
BEGIN OF LINE,
PUSHBUTTON 2(10) BUT1 USER-COMMAND CLI1,
PUSHBUTTON 12(10) TEXT-020 USER-COMMAND CLI2,
END OF LINE,
BEGIN OF LINE,
PUSHBUTTON 2(10) BUT3 USER-COMMAND CLI3,
PUSHBUTTON 12(10) TEXT-040 USER-COMMAND CLI4,
END OF LINE,
END OF SCREEN 500.
AT SELECTION-SCREEN.
MESSAGE I888(SABAPDEMOS) WITH TEXT-001 SSCRFIELDS-UCOMM.
CASE SSCRFIELDS-UCOMM.
WHEN ‘CLI1‘.
FLAG = ‘1‘.
WHEN ‘CLI2‘.
FLAG = ‘2‘.
WHEN ‘CLI3‘.
FLAG = ‘3‘.
WHEN ‘CLI4‘.
FLAG = ‘4‘.
ENDCASE.
START-OF-SELECTION.
TIT = ‘FOUR BUTTONS‘.
BUT1 = ‘BUTTON 1‘.
BUT3 = ‘BUTTON 3‘.
CALL SELECTION-SCREEN 500 STARTING AT 10 10.
CASE FLAG.
WHEN ‘1‘.
WRITE / ‘BUTTON 1 WAS CLICKED‘.
WHEN ‘2‘.
WRITE / ‘BUTTON 2 WAS CLICKED‘.
WHEN ‘3‘.
WRITE / ‘BUTTON 3 WAS CLICKED‘.
WHEN ‘4‘.
WRITE / ‘BUTTON 4 WAS CLICKED‘.
WHEN OTHERS.
WRITE / ‘NO BUTTON WAS CLICKED‘.
ENDCASE.