針對此需求大概分為兩個目標
A) 如何做到 Double Click
針對要觸發 Double Click 的元件,設定 Pesponds to double-click
再 GUI Status 的 Choose 加入 Code
DATA: G_LINE TYPE I.
DATA: G_DBL_AREA(20) TYPE C.
"透過 Get Cursor 捉取目前滑鼠點擊的行數以及哪個 Area (點在哪個 Table Control 上)
GET CURSOR LINE G_LINE AREA G_DBL_AREA.
REPORT Z_EX_TC_DBCLOCK.
CONTROLS: TC_CONTROL1 TYPE TABLEVIEW USING SCREEN 0100,
TC_CONTROL2 TYPE TABLEVIEW USING SCREEN 0100.
DATA : G_TC_LINES1 LIKE SY-LOOPC,
G_TC_LINES2 LIKE SY-LOOPC.
DATA : BEGIN OF I_TAB1 OCCURS 0,
TEXT(100) TYPE C,
END OF I_TAB1.
DATA : I_TAB2 LIKE STANDARD TABLE OF I_TAB1 WITH HEADER LINE.
DATA : WA_TAB1 LIKE I_TAB1,
WA_TAB2 LIKE I_TAB2.
DATA : OK_CODE LIKE SY-UCOMM.
DATA: G_LINE TYPE I,
G_LINE_STR(20) TYPE C.
DATA: G_DBL_AREA(20) TYPE C.
DATA: G_MSG(200) TYPE C.
"產生 Internal table 的資料
I_TAB1-TEXT = 'TABLE CONTROL 1 LINE 1'.
APPEND I_TAB1.
I_TAB1-TEXT = 'TABLE CONTROL 1 LINE 2'.
APPEND I_TAB1.
I_TAB1-TEXT = 'TABLE CONTROL 1 LINE 3'.
APPEND I_TAB1.
I_TAB1-TEXT = 'TABLE CONTROL 1 LINE 4'.
APPEND I_TAB1.
I_TAB1-TEXT = 'TABLE CONTROL 1 LINE 5'.
APPEND I_TAB1.
I_TAB1-TEXT = 'TABLE CONTROL 1 LINE 6'.
APPEND I_TAB1.
I_TAB1-TEXT = 'TABLE CONTROL 1 LINE 7'.
APPEND I_TAB1.
I_TAB1-TEXT = 'TABLE CONTROL 1 LINE 8'.
APPEND I_TAB1.
I_TAB1-TEXT = 'TABLE CONTROL 1 LINE 9'.
APPEND I_TAB1.
I_TAB1-TEXT = 'TABLE CONTROL 1 LINE 10'.
APPEND I_TAB1.
I_TAB2-TEXT = 'TABLE CONTROL 2 LINE 1'.
APPEND I_TAB2.
I_TAB2-TEXT = 'TABLE CONTROL 2 LINE 2'.
APPEND I_TAB2.
I_TAB2-TEXT = 'TABLE CONTROL 2 LINE 3'.
APPEND I_TAB2.
I_TAB2-TEXT = 'TABLE CONTROL 2 LINE 4'.
APPEND I_TAB2.
I_TAB2-TEXT = 'TABLE CONTROL 2 LINE 5'.
APPEND I_TAB2.
I_TAB2-TEXT = 'TABLE CONTROL 2 LINE 6'.
APPEND I_TAB2.
I_TAB2-TEXT = 'TABLE CONTROL 2 LINE 7'.
APPEND I_TAB2.
I_TAB2-TEXT = 'TABLE CONTROL 2 LINE 8'.
APPEND I_TAB2.
I_TAB2-TEXT = 'TABLE CONTROL 2 LINE 9'.
APPEND I_TAB2.
I_TAB2-TEXT = 'TABLE CONTROL 2 LINE 10'.
APPEND I_TAB2.
CALL SCREEN 0100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'S0100'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'EXIT' OR 'BACK' OR 'CANC'.
LEAVE TO SCREEN 0.
"因為在 GUI Status 的 choose 加入 DBCLK Code,因此此時畫面的 Code 可以接到 DBCLK
WHEN 'DBCLK'.
GET CURSOR LINE G_LINE AREA G_DBL_AREA.
"當目前 Table control scrolling bar 不是在第一筆時,要加上 TOP LINE 避勉捉錯筆
IF G_DBL_AREA = 'TC_CONTROL1'.
G_LINE = G_LINE + TC_CONTROL1-TOP_LINE - 1.
ELSEIF G_DBL_AREA = 'TC_CONTROL2'.
G_LINE = G_LINE + TC_CONTROL2-TOP_LINE - 1.
ENDIF.
WRITE G_LINE TO G_LINE_STR NO-GROUPING.
CONDENSE G_LINE_STR.
CONCATENATE 'LINE:' G_LINE_STR ', Table Contrl Name:' G_DBL_AREA INTO G_MSG.
MESSAGE G_MSG TYPE 'I'.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module SET_LINES_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE SET_LINES_0100 OUTPUT.
DESCRIBE TABLE I_TAB1 LINES G_TC_LINES1.
DESCRIBE TABLE I_TAB2 LINES G_TC_LINES2.
ENDMODULE. " SET_LINES_0100 OUTPUT
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
MODULE SET_LINES_0100.
LOOP AT I_TAB1
INTO WA_TAB1
WITH CONTROL TC_CONTROL1
CURSOR TC_CONTROL1-CURRENT_LINE.
ENDLOOP.
LOOP AT I_TAB2
INTO WA_TAB2
WITH CONTROL TC_CONTROL2
CURSOR TC_CONTROL2-CURRENT_LINE.
ENDLOOP.
*
PROCESS AFTER INPUT.
LOOP AT I_TAB1.
ENDLOOP.
LOOP AT I_TAB2.
ENDLOOP.
MODULE USER_COMMAND_0100.
沒有留言:
張貼留言