Multiple ALV Grids on the same window.

10-11  Source: Network gathering  Views:4 

Advertisement
Hi,
Can someone tell me if it's possible to display multiple ALV grids on the same window.If so how is it done.Please note that I am talking about Grid Display and not List Display.
Regards,
Swathi Balakrishnan
Hi,
This can be done even i have done a report.
Its very simple create three containers as below.
Just repeat three times if u need to create three containers.
See this sample code using custom container.
START-OF-SELECTION.
Begin of process logic
  CALL SCREEN '0100'.
END-OF-SELECTION.
*&      Module  STATUS_0100  OUTPUT
      text
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS01'.
  SET TITLEBAR 'SALESTTL'.
A L V    G R I D
  IF o_grid_container IS INITIAL.
    CREATE OBJECT o_grid_container
      EXPORTING
        container_name = '<b>CCONTAINER1</b>'.
    CREATE OBJECT o_grid
      EXPORTING
        i_appl_events = 'X'
        i_parent = o_grid_container.
<b>FOR first A L V    G R I D</b>
    PERFORM set_grid_field_catalog
                CHANGING i_grid_fcat.
    PERFORM modify_grid_fcat_predisplay
                CHANGING i_grid_fcat.
    PERFORM set_grid_layout_set
                CHANGING struct_grid_lset.
    PERFORM sort_outtable CHANGING i_sort_fcat.
PERFORM populate_grid_data  TABLES i_grid_outs i_grid_outs_pro.
    SORT i_grid_outs BY year month.
    CALL METHOD o_grid->set_table_for_first_display
      EXPORTING
        i_bypassing_buffer    =  space
        is_variant            =  ws_f_grid_disvar
        i_save                =  ws_c_grid_save
        is_layout             =  struct_grid_lset
      CHANGING
        it_outtab             =  i_grid_outs[]
        it_fieldcatalog       =  i_grid_fcat[]
        it_sort               =  i_sort_fcat.      " Period
  ENDIF.
  IF o_grid1_container IS INITIAL.
    CREATE OBJECT o_grid1_container
      EXPORTING
        container_name = '<b>CCONTAINER2</b>'.
    CREATE OBJECT o_grid1
      EXPORTING
        i_appl_events = 'X'
        i_parent = o_grid1_container.
*<b> FOR SECOND ALV GRID</b>
    PERFORM set_grid1_field_catalog
                CHANGING i_grid1_fcat.
    PERFORM modify_grid1_fcat_predisplay
                CHANGING i_grid1_fcat.
    PERFORM set_grid1_layout_set
                CHANGING struct_grid1_lset.
    PERFORM sort_outtable1 CHANGING i_sort_fcat1.
PERFORM populate_grid1_data  TABLES i_grid1_outs i_grid1_outs_pro.
    SORT i_grid1_outs BY year month.
    CALL METHOD o_grid1->set_table_for_first_display
      EXPORTING
        i_bypassing_buffer    =  space
        is_variant            =  ws_f_grid_disvar
        i_save                =  ws_c_grid_save
        is_layout             =  struct_grid1_lset
      CHANGING
        it_outtab             =  i_grid1_outs[]
        it_fieldcatalog       =  i_grid1_fcat[]
        it_sort               =  i_sort_fcat1.      " Period
  ENDIF.
  IF o_grid2_container IS INITIAL.
    CREATE OBJECT o_grid2_container
      EXPORTING
        container_name = '<b>CCONTAINER3</b>'.
    CREATE OBJECT o_grid2
      EXPORTING
        i_appl_events = 'X'
        i_parent = o_grid2_container.
<b>FOR THIRD ALV GRID</b>
    PERFORM set_grid2_field_catalog
                CHANGING i_grid2_fcat.
    PERFORM modify_grid2_fcat_predisplay
                CHANGING i_grid2_fcat.
    PERFORM set_grid2_layout_set
                CHANGING struct_grid2_lset.
PERFORM populate_grid2_data  TABLES i_grid2_outs i_grid2_outs_pro.
    SORT i_grid2_outs BY year month.
    PERFORM sort_outtable2 CHANGING i_sort_fcat2.
    CALL METHOD o_grid2->set_table_for_first_display
      EXPORTING
        i_bypassing_buffer    =  space
        is_variant            =  ws_f_grid_disvar
        i_save                =  ws_c_grid_save
        is_layout             =  struct_grid2_lset
      CHANGING
        it_outtab             =  i_grid2_outs[]
        it_fieldcatalog       =  i_grid2_fcat[]
        it_sort               =  i_sort_fcat2.      " Period
  ENDIF.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&      Module  USER_COMMAND_0100  INPUT
      text
MODULE user_command_0100 INPUT.
As the events are registered as application events, control is first
passed to the program's PAI. The call 'cl_gui_cfw=>dispatch' will
forward control to ABAP object event handling and the appropriate
event handler will be called (if present). This allows the user to
selectively process events.
  DATA: i_return_code TYPE i .
  CALL METHOD cl_gui_cfw=>dispatch
      IMPORTING return_code = i_return_code.
  save_ok = ok_code.
  CASE save_ok.
    WHEN 'BACK' OR 'END' OR 'CANC'.
      PERFORM exit_program.
  ENDCASE.
  CLEAR save_ok.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&      Form  EXIT_PROGRAM
      text
FORM exit_program.
  CALL METHOD o_grid_container->free.
  CALL METHOD o_grid1_container->free.
  CALL METHOD o_grid2_container->free.
  CALL METHOD cl_gui_cfw=>flush.
  IF sy-subrc NE 0.
    Error in FLush
  ENDIF.
  LEAVE TO SCREEN 0.
ENDFORM.                  " EXIT_PROGRAM
If u want get more idea revert back to me.
Thanks & Regards,
Judith.
Related articles