Skip to Content
0
Former Member
Feb 14, 2007 at 04:58 AM

Two ALV Grids in a same screen

46 Views

Hi Could anybody please advice me, as I'm trying to display two grids in a same screen , but grids are displaying side by side, I need to display them one by one...please advice me....Thanks in advance....

*-- global data definitions  for ALV
*-- ALV Grid Instance Reference
DATA  :  w_grid  TYPE REF TO CL_GUI_ALV_GRID,
         w_grid1 TYPE REF TO CL_GUI_ALV_GRID,
         w_grid2 TYPE REF TO CL_GUI_ALV_GRID,
*-- Container Instance Reference
        w_dock_container  TYPE REF TO cl_gui_docking_container,
        w_dock_container1 TYPE REF TO cl_gui_docking_container,
        w_dock_container2 TYPE REF TO cl_gui_docking_container,
*-- Field catalog table
        w_lvc_t_fcat  TYPE lvc_t_fcat,
        w_lvc_t_fcat1 TYPE lvc_t_fcat,
        w_lvc_t_fcat2 TYPE lvc_t_fcat,
*-- Layout structure
        w_lvc_layo  TYPE lvc_s_layo,
        w_lvc_layo1 TYPE lvc_s_layo,
        w_lvc_layo2 TYPE lvc_s_layo,
*-- disvariant
        w_disvariant TYPE disvariant,

*&---------------------------------------------------------------------*
*&      Module  STATUS_9700  OUTPUT
*&---------------------------------------------------------------------*
*       status for 9700
*----------------------------------------------------------------------*
MODULE STATUS_9700 OUTPUT.
*-- pf status
  SET PF-STATUS 'YIBRK_VAL_REPORT'.
*-- title bar
  SET TITLEBAR 'YIBRK_VAL_REPORT'.
*-- display valuations report.
  PERFORM display_valuations.
*-- display exceptions
  PERFORM display_exceptions.
ENDMODULE.                 " STATUS_9700  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9700  INPUT
*&---------------------------------------------------------------------*
*       user command for 9700
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9700 INPUT.
  CASE SY-UCOMM.
    WHEN 'BACK'.                              " BACK BUTTON
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'EXIT' OR 'CANCEL'.                  " EXIT AND CANCEL BUTTON
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_9700  INPUT
*&---------------------------------------------------------------------*
*&      Form  display_valuations
*&---------------------------------------------------------------------*
*       display valuation report
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display_valuations .
  IF w_grid1 IS INITIAL.

*-- creating custom container instance
    CREATE OBJECT W_DOCK_CONTAINER1
      EXPORTING
        RATIO          = '95'
*    I_SHELLSTYLE      = 0
*    I_LIFETIME        =
*    I_PARENT          =
*    I_APPL_EVENTS     = space
*    I_PARENTDBG       =
*    I_APPLOGPARENT    =
*    I_GRAPHICSPARENT  =
*    I_NAME            =
    EXCEPTIONS
         CNTL_ERROR                  = 1
         CNTL_SYSTEM_ERROR           = 2
         CREATE_ERROR                = 3
         LIFETIME_ERROR              = 4
         LIFETIME_DYNPRO_DYNPRO_LINK = 5
         others                      = 6.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

*-- creating ALV grid instance
    CREATE OBJECT W_GRID1
      EXPORTING
*    I_SHELLSTYLE      = 0
*    I_LIFETIME        =
        I_PARENT          =  W_DOCK_CONTAINER1
*    I_APPL_EVENTS     = space
*    I_PARENTDBG       =
*    I_APPLOGPARENT    =
*    I_GRAPHICSPARENT  =
*    I_NAME            =
      EXCEPTIONS
        ERROR_CNTL_CREATE = 1
        ERROR_CNTL_INIT   = 2
        ERROR_CNTL_LINK   = 3
        ERROR_DP_CREATE   = 4
        others            = 5.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

*-- preparing field catalog
    PERFORM prepare_fieldcat_valuations CHANGING w_lvc_t_fcat1.

*-- preparing layout structure
    PERFORM prepare_layout_valuations CHANGING w_lvc_layo1.

*-- disvariant
    W_DISVARIANT-REPORT = SY-REPID.

*-- display alv grid
    CALL METHOD W_GRID1->SET_TABLE_FOR_FIRST_DISPLAY
  EXPORTING
*    I_BUFFER_ACTIVE               =
*    I_BYPASSING_BUFFER            =
*    I_CONSISTENCY_CHECK           =
*    I_STRUCTURE_NAME              =
        IS_VARIANT                    = W_DISVARIANT
        I_SAVE                        = c_a
*    I_DEFAULT                     = 'X'
        IS_LAYOUT                     = W_LVC_LAYO1
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
*    IT_TOOLBAR_EXCLUDING          =
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
*    IT_EXCEPT_QINFO               =
      CHANGING
        IT_OUTTAB                     = t_val_report[]
        IT_FIELDCATALOG               = W_LVC_T_FCAT1
*    IT_SORT                       =
*    IT_FILTER                     =
      EXCEPTIONS
        INVALID_PARAMETER_COMBINATION = 1
        PROGRAM_ERROR                 = 2
        TOO_MANY_LINES                = 3
        others                        = 4.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ELSE.
*-- refresh table
    CALL METHOD W_GRID1->refresh_table_DISPLAY
*      EXPORTING
         EXCEPTIONS
           finished = 1
           others   = 2.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ENDIF.

ENDFORM.                    " display_valuations
*&---------------------------------------------------------------------*
*&      Form  display_exceptions
*&---------------------------------------------------------------------*
*       display exception report
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display_exceptions .
  IF w_grid2 IS INITIAL.

*-- creating custom container instance
    CREATE OBJECT W_DOCK_CONTAINER2
      EXPORTING
        RATIO          = '95'
*    I_SHELLSTYLE      = 0
*    I_LIFETIME        =
*    I_PARENT          =
*    I_APPL_EVENTS     = space
*    I_PARENTDBG       =
*    I_APPLOGPARENT    =
*    I_GRAPHICSPARENT  =
*    I_NAME            =
    EXCEPTIONS
         CNTL_ERROR                  = 1
         CNTL_SYSTEM_ERROR           = 2
         CREATE_ERROR                = 3
         LIFETIME_ERROR              = 4
         LIFETIME_DYNPRO_DYNPRO_LINK = 5
         others                      = 6.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

*-- creating ALV grid instance
    CREATE OBJECT W_GRID2
      EXPORTING
*    I_SHELLSTYLE      = 0
*    I_LIFETIME        =
        I_PARENT          =  W_DOCK_CONTAINER2
*    I_APPL_EVENTS     = space
*    I_PARENTDBG       =
*    I_APPLOGPARENT    =
*    I_GRAPHICSPARENT  =
*    I_NAME            =
      EXCEPTIONS
        ERROR_CNTL_CREATE = 1
        ERROR_CNTL_INIT   = 2
        ERROR_CNTL_LINK   = 3
        ERROR_DP_CREATE   = 4
        others            = 5.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

*-- preparing field catalog
    PERFORM prepare_fieldcat_exceptions CHANGING w_lvc_t_fcat2.

*-- preparing layout structure
    PERFORM prepare_layout_exceptions CHANGING w_lvc_layo2.

*-- disvariant
    W_DISVARIANT-REPORT = SY-REPID.

*-- display alv grid
    CALL METHOD W_GRID2->SET_TABLE_FOR_FIRST_DISPLAY
  EXPORTING
*    I_BUFFER_ACTIVE               =
*    I_BYPASSING_BUFFER            =
*    I_CONSISTENCY_CHECK           =
*    I_STRUCTURE_NAME              =
        IS_VARIANT                    = W_DISVARIANT
        I_SAVE                        = c_a
*    I_DEFAULT                     = 'X'
        IS_LAYOUT                     = W_LVC_LAYO2
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
*    IT_TOOLBAR_EXCLUDING          =
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
*    IT_EXCEPT_QINFO               =
      CHANGING
        IT_OUTTAB                     = t_val_report_exce[]
        IT_FIELDCATALOG               = W_LVC_T_FCAT2
*    IT_SORT                       =
*    IT_FILTER                     =
      EXCEPTIONS
        INVALID_PARAMETER_COMBINATION = 1
        PROGRAM_ERROR                 = 2
        TOO_MANY_LINES                = 3
        others                        = 4.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ELSE.
*-- refresh table
    CALL METHOD W_GRID2->refresh_table_DISPLAY
*      EXPORTING
         EXCEPTIONS
           finished = 1
           others   = 2.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
  ENDIF.

ENDFORM.                    " display_exceptions
*&---------------------------------------------------------------------*
*&      Form  prepare_fieldcat_valuations
*&---------------------------------------------------------------------*
*       field catalog for display valuations
*----------------------------------------------------------------------*
*      <--P_W_LVC_T_FCAT1  text
*----------------------------------------------------------------------*
FORM prepare_fieldcat_valuations  CHANGING P_W_LVC_T_FCAT1
                                    TYPE lvc_t_fcat.

  DATA: ls_fcat TYPE lvc_s_fcat.
*-- Plan Type
  ls_fcat-fieldname = 'PLTYP'.
  ls_fcat-ref_table = 'T_VAL_REPORT'.
  ls_fcat-outputlen = '10'.
  ls_fcat-coltext   = 'Plan Type'.
  APPEND ls_fcat to p_w_lvc_t_fcat1.
  CLEAR  ls_fcat.

*-- Plan Option
  ls_fcat-fieldname = 'PLAN_OPT'.
  ls_fcat-ref_table = 'T_VAL_REPORT'.
  ls_fcat-outputlen = '10'.
  ls_fcat-coltext   = 'Plan Option'.
  APPEND ls_fcat to p_w_lvc_t_fcat1.
  CLEAR  ls_fcat.

*-- Currency
  ls_fcat-fieldname = 'CURRENCY'.
  ls_fcat-ref_table = 'T_VAL_REPORT'.
  ls_fcat-outputlen = '10'.
  ls_fcat-coltext   = 'Currency'.
  APPEND ls_fcat to p_w_lvc_t_fcat1.
  CLEAR  ls_fcat.

*-- BALANCE
  ls_fcat-fieldname = 'BALANCE'.
  ls_fcat-ref_table = 'T_VAL_REPORT'.
  ls_fcat-outputlen = '18'.
  ls_fcat-coltext   = 'Balances'.
  APPEND ls_fcat to p_w_lvc_t_fcat1.
  CLEAR  ls_fcat.

*-- Earnings Percentage
  ls_fcat-fieldname = 'PERCENTAGE'.
  ls_fcat-ref_table = 'T_VAL_REPORT'.
  ls_fcat-outputlen = '12'.
  ls_fcat-coltext   = 'Percentage'.
  APPEND ls_fcat to p_w_lvc_t_fcat1.
  CLEAR  ls_fcat.

*-- Earnings amount
  ls_fcat-fieldname = 'EAMOUNT'.
  ls_fcat-ref_table = 'T_VAL_REPORT'.
  ls_fcat-outputlen = '18'.
  ls_fcat-coltext   = 'Earnings Amount'.
  APPEND ls_fcat to p_w_lvc_t_fcat1.
  CLEAR  ls_fcat.

*-- Balance after Earnings
  ls_fcat-fieldname = 'EBALANCE'.
  ls_fcat-ref_table = 'T_VAL_REPORT'.
  ls_fcat-outputlen = '22'.
  ls_fcat-coltext   = 'Balance after Earnings'.
  APPEND ls_fcat to p_w_lvc_t_fcat1.
  CLEAR  ls_fcat.

ENDFORM.                    " prepare_fieldcat_valuations
*&---------------------------------------------------------------------*
*&      Form  prepare_layout_valuations
*&---------------------------------------------------------------------*
*      prepare layout for valuation report
*----------------------------------------------------------------------*
*      <--P_W_LVC_LAYO1  text
*----------------------------------------------------------------------*
FORM prepare_layout_valuations  CHANGING P_W_LVC_LAYO1 TYPE lvc_s_layo.
  P_W_LVC_LAYO1-zebra       = c_x.
  P_W_LVC_LAYO1-grid_title  = c_title.
  P_W_LVC_LAYO1-SEL_MODE    = c_a.
  P_W_LVC_LAYO1-NO_TOOLBAR  = c_x.
ENDFORM.                    " prepare_layout_valuations
*&---------------------------------------------------------------------*
*&      Form  prepare_fieldcat_exceptions
*&---------------------------------------------------------------------*
*       field catalog for exception report
*----------------------------------------------------------------------*
*      <--P_W_LVC_T_FCAT2  text
*----------------------------------------------------------------------*
FORM prepare_fieldcat_exceptions  CHANGING P_W_LVC_T_FCAT2
                                           TYPE lvc_t_fcat.
  DATA: ls_fcat TYPE lvc_s_fcat.

*-- GIN
  ls_fcat-fieldname = 'GIN'.
  ls_fcat-ref_table = 'T_VAL_REPORT_EXCE'.
  ls_fcat-outputlen = '10'.
  ls_fcat-coltext   = 'GIN'.
  APPEND ls_fcat to p_w_lvc_t_fcat2.
  CLEAR  ls_fcat.

*-- Plan Type
  ls_fcat-fieldname = 'PLTYP'.
  ls_fcat-ref_table = 'T_VAL_REPORT_EXCE'.
  ls_fcat-outputlen = '10'.
  ls_fcat-coltext   = 'Plan Type'.
  APPEND ls_fcat to p_w_lvc_t_fcat2.
  CLEAR  ls_fcat.

*-- Plan Option
  ls_fcat-fieldname = 'PLAN_OPT'.
  ls_fcat-ref_table = 'T_VAL_REPORT_EXCE'.
  ls_fcat-outputlen = '10'.
  ls_fcat-coltext   = 'Plan Option'.
  APPEND ls_fcat to p_w_lvc_t_fcat2.
  CLEAR  ls_fcat.

*-- BALANCE
  ls_fcat-fieldname = 'BALANCE'.
  ls_fcat-ref_table = 'T_VAL_REPORT_EXCE'.
  ls_fcat-outputlen = '18'.
  ls_fcat-coltext   = 'Balances'.
  APPEND ls_fcat to p_w_lvc_t_fcat2.
  CLEAR  ls_fcat.

*-- Reason
  ls_fcat-fieldname = 'REASON'.
  ls_fcat-ref_table = 'T_VAL_REPORT_EXCE'.
  ls_fcat-outputlen = '25'.
  ls_fcat-coltext   = 'Reason'.
  APPEND ls_fcat to p_w_lvc_t_fcat2.
  CLEAR  ls_fcat.

ENDFORM.                    " prepare_fieldcat_exceptions
*&---------------------------------------------------------------------*
*&      Form  prepare_layout_exceptions
*&---------------------------------------------------------------------*
*      prepare layout for exception report
*----------------------------------------------------------------------*
*      <--P_W_LVC_LAYO2  text
*----------------------------------------------------------------------*
FORM prepare_layout_exceptions  CHANGING P_W_LVC_LAYO2 TYPE lvc_s_layo.
  P_W_LVC_LAYO2-zebra       = c_x.
  P_W_LVC_LAYO2-grid_title  = c_title.
  P_W_LVC_LAYO2-SEL_MODE    = c_a.
  P_W_LVC_LAYO2-NO_TOOLBAR  = c_x.

ENDFORM.                    " prepare_layout_exceptions