2015年4月4日 星期六

ABAP - CL_GUI_DOCKING_CONTAINER & CL_GUI_SPLITTER_CONTAINER

透過 CL_GUI_DOCKING_CONTAINER 建立一個可以放入各種物件的容器,但如果需要分割數個區塊供不同功能使用 (e.g. 左邊樹狀結構,右邊顯示資料),則需要再搭配 CL_GUI_SPLITTER_CONTAINER


主要宣告的物件如下,主要是透過 CL_GUI_DOCKING_CONTAINER 建立一個全螢幕的 CONTAINER,再透過 SPLITTER_1 把 CONTAINER 切成四個區塊,再透過 CL_GUI_CONTAINER 填入四個區塊中

"CONTAINER
DATA: G_CONTAINER1 type ref to CL_GUI_DOCKING_CONTAINER,   "MAIN CONTAINER
      G_CONTAINER2 type ref to CL_GUI_CONTAINER,
      G_CONTAINER3 type ref to cl_gui_container,
      G_CONTAINER4 type ref to cl_gui_container,
      G_CONTAINER5 type ref to cl_gui_container.

DATA splitter_1 TYPE REF TO CL_GUI_SPLITTER_CONTAINER.


Sample Code :

REPORT Z_EX_CONTAINER_SPLITTER NO STANDARD PAGE HEADING
                               LINE-SIZE 255 LINE-COUNT 65.

DATA: OK_CODE LIKE SY-UCOMM.

"CONTAINER
DATA: G_CONTAINER1 type ref to CL_GUI_DOCKING_CONTAINER,   "MAIN CONTAINER
      G_CONTAINER2 type ref to CL_GUI_CONTAINER,
      G_CONTAINER3 type ref to cl_gui_container,
      G_CONTAINER4 type ref to cl_gui_container,
      G_CONTAINER5 type ref to cl_gui_container.

DATA splitter_1 TYPE REF TO CL_GUI_SPLITTER_CONTAINER.

START-OF-SELECTION.

  CALL SCREEN 0100.

END-OF-SELECTION.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.

  SET PF-STATUS 'S0100'.
  SET TITLEBAR 'T0100'.

  PERFORM CREATE_CONTAINER.

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.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_0100  INPUT


*&---------------------------------------------------------------------*
*&      Form  CREATE_LOCAL_TREE
*&---------------------------------------------------------------------*
*       Create Local Tree Node
*----------------------------------------------------------------------*
FORM CREATE_CONTAINER.

  DATA: REPID TYPE SY-REPID,
        DYNNR TYPE SY-DYNNR.

  REPID = SY-REPID.
  DYNNR = SY-DYNNR.

  "建立 CONTAINER 在目前程式的 SCREEN 0100
  CREATE OBJECT G_CONTAINER1
                EXPORTING REPID     = REPID
                          DYNNR     = DYNNR
                          SIDE      = CL_GUI_DOCKING_CONTAINER=>DOCK_AT_LEFT  "靠左
                          EXTENSION = 99999.                                  "寬度

   "建立 Splitter,並設定目前 Splitter 要把 Container 切成四等份
   CREATE OBJECT splitter_1
                 EXPORTING
                 parent = G_CONTAINER1
                 rows = 2
                 columns = 2.

   "設定 Splitter 外觀
   CALL METHOD splitter_1->SET_ROW_SASH
     exporting
       id = 1
       type  = cl_gui_splitter_container=>type_sashvisible
       value = cl_gui_splitter_container=>true.

   "設定預設 Splitter1 的高度
   CALL METHOD splitter_1->SET_ROW_HEIGHT
     EXPORTING
       ID     = 1
       HEIGHT = 5.

   "getting the reference for the splited container( row 1 & col 1 container )
   CALL METHOD splitter_1->get_container
   EXPORTING
   row = 1
   column = 1
   RECEIVING
   container = G_CONTAINER2.

   CALL METHOD splitter_1->get_container
   EXPORTING
   row = 1
   column = 2
   RECEIVING
   container = G_CONTAINER3.

   CALL METHOD splitter_1->get_container
   EXPORTING
   row = 2
   column = 1
   RECEIVING
   container = G_CONTAINER4.

   CALL METHOD splitter_1->get_container
   EXPORTING
   row = 2
   column = 2
   RECEIVING
   container = G_CONTAINER5.

ENDFORM.                    " CREATE_CONTAINER

需要透過 SCREEN 0100 來呈現目前 CONTAINER 與 SPLITTER,並且在 0100 的 MODULE STATUS_0100 OUTPUT.中執行 CREATE_CONTAINER。


透過下面的 SET_ROW_SASH 來設定 Splitter 的樣式

CALL METHOD splitter_1->SET_ROW_SASH
  exporting
    id = 1
    type  = cl_gui_splitter_container=>type_sashvisible
    value = cl_gui_splitter_container=>true.

不執行上面的程式,預設的樣式如下

另外透過寬度 99999 讓 Container 能夠放大到最大

CREATE OBJECT G_CONTAINER1
  EXPORTING REPID     = REPID
    DYNNR     = DYNNR
    SIDE      = CL_GUI_DOCKING_CONTAINER=>DOCK_AT_LEFT  "靠左
    EXTENSION = 99999.                                     "寬度

另外透過下面的語法將目前的 Container 切成四個區塊,再依目前 Splitter 個區塊填入 Container

CREATE OBJECT splitter_1
              EXPORTING
              parent = G_CONTAINER1
              rows = 2
              columns = 2.

CALL METHOD splitter_1->get_container
  EXPORTING
  row = 1
  column = 1
  RECEIVING
  container = G_CONTAINER2.

沒有留言:

張貼留言

How to install & specified python version or distreibtuion package version in google colab

在買了 RTX 3080 要來 挖礦...  嗯~是跑機器學習後,結果發現了 GOOGLE COLAB,其實之前在「GAN 對抗式生成網路」一書就有看到,但資訊人就是什麼都想自己安裝,在本機用 Anaconda + pyCharm 弄了 GPU 環境,結果有天從新竹回家發現家裡沒...