메뉴 건너뛰기

SAP 한국 커뮤니티




다중 ALV Grid 사이즈 조절 Tip

꿀꿀윤뚱67 2019.11.27 13:57 조회 수 : 62

MODULE PREPARE_ALV_GRID_0100 OUTPUT.
  G_CALL_ALV = '1'.
  PERFORM CREATE_AND_INIT_ALV USING GR_CONT1  GR_GRID1
                                    100  "HEIGht
                                    1    "ROWS
  IF GT_011T[] IS NOT INITIAL.
    G_CALL_ALV = '2'.
    PERFORM CREATE_AND_INIT_ALV USING GR_CONT2  GR_GRID2
                                      60  "HEIGht
                                      2    "ROWS
  ENDIF.
  IF GT_012T[] IS NOT INITIAL.
    G_CALL_ALV = '3'.
    PERFORM CREATE_AND_INIT_ALV USING GR_CONT3   GR_GRID3
                                      60  "HEIGht
                                      3    "ROWS
  ENDIF.
  IF GT_013T[] IS NOT INITIAL.
    G_CALL_ALV = '4'.
    PERFORM CREATE_AND_INIT_ALV USING GR_CONT4  GR_GRID4
                                      60  "HEIGht
                                      4    "ROWS
  ENDIF.
ENDMODULE.                 " PREPARE_ALV_GRID_0100  OUTPUT

-----------------------------------------------------------------------------------

FORM CREATE_AND_INIT_ALV
            USING PR_CONT   TYPE REF TO CL_GUI_CONTAINER
                  PR_GRID   TYPE REF TO CL_GUI_ALV_GRID
                  P_HEIGHT
                  P_ROW_ID
                  PS_LAYO   TYPE LVC_S_LAYO
                  PT_FCAT   TYPE LVC_T_FCAT
                  PT_OUTTAB TYPE STANDARD TABLE.

  IF GR_GRID1 IS INITIAL.
    CREATE OBJECT GR_CONTAINER
      EXPORTING
        CONTAINER_NAME = 'G_CON'.
    CREATE OBJECT GR_SPLITTER
      EXPORTING
        PARENT  = GR_CONTAINER
        ROWS    = 4
        COLUMNS = 1.

    GR_SPLITTER->SET_ROW_MODE(
                    MODE = CL_GUI_SPLITTER_CONTAINER=>MODE_RELATIVE ).

    GR_SPLITTER->SET_ROW_HEIGHT( ID = 1 HEIGHT = 1 ).  " %

*   HTML TOP-OF-PAGE
    CALL METHOD GR_SPLITTER->GET_CONTAINER
      EXPORTING
        ROW       = 1  "TOP-OF-PAGE
        COLUMN    = 1
      RECEIVING
        CONTAINER = GR_CONT1.
*
  ELSE. "MAIN LIST 아니면 데이타 있을때만 출력
*    CHECK PT_OUTTAB IS NOT INITIAL.

    CASE G_CALL_ALV.
      WHEN '1'.  "GR_GRID2
        GR_SPLITTER->SET_ROW_HEIGHT( ID = 1 HEIGHT = 100 ).  "%

      WHEN '2'.  "GR_GRID3
        GR_SPLITTER->SET_ROW_HEIGHT( ID = 1 HEIGHT = 50 ).  "%
        GR_SPLITTER->SET_ROW_HEIGHT( ID = 2 HEIGHT = 50 ).  "%

      WHEN '3'.  "GR_GRID
        GR_SPLITTER->SET_ROW_HEIGHT( ID = 1 HEIGHT = 30 ).  "%
        GR_SPLITTER->SET_ROW_HEIGHT( ID = 2 HEIGHT = 30 ).  "%
        GR_SPLITTER->SET_ROW_HEIGHT( ID = 3 HEIGHT = 30 ).  "%
      WHEN '4'.  "GR_GRID
        GR_SPLITTER->SET_ROW_HEIGHT( ID = 1 HEIGHT = 25 ).  "%
        GR_SPLITTER->SET_ROW_HEIGHT( ID = 2 HEIGHT = 25 ).  "%
        GR_SPLITTER->SET_ROW_HEIGHT( ID = 3 HEIGHT = 25 ).  "%
        GR_SPLITTER->SET_ROW_HEIGHT( ID = 4 HEIGHT = 25 ).  "%
    ENDCASE.

  ENDIF.
  GR_SPLITTER->SET_ROW_HEIGHT( ID = P_ROW_ID HEIGHT = P_HEIGHT ).  "%

  IF PR_GRID IS INITIAL.
    CALL METHOD GR_SPLITTER->GET_CONTAINER
      EXPORTING
        ROW       = P_ROW_ID
        COLUMN    = 1
      RECEIVING
        CONTAINER = PR_CONT.

    CREATE OBJECT PR_GRID
      EXPORTING
        I_PARENT      = PR_CONT
        I_APPL_EVENTS = 'X'.

    PS_LAYO-COL_OPT = 'X'.
    PS_LAYO-ZEBRA   = 'X'.

    CALL METHOD PR_GRID->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
        IS_LAYOUT            = PS_LAYO
        IT_TOOLBAR_EXCLUDING = GT_EXCLUDE
      CHANGING
        IT_FIELDCATALOG      = PT_FCAT
        IT_OUTTAB            = PT_OUTTAB.

    IF GR_GRID1 IS NOT INITIAL.
      SET HANDLER GR_RECEIVER->HANDLE_TOP_OF_PAGE FOR GR_GRID1.
      PERFORM CREATE_TOP_OF_PAGE  USING GR_GRID1.
    ENDIF.
  ENDIF.

ENDFORM.                               "CREATE_AND_INIT_ALV