Sep 3, 2015

Multiple ALV Grids on One Window

A sample program to create multiple ALV in one window

By Ramesh T

Codes:
REPORT ztest01.

DATA : splitter_1  TYPE REF TO cl_gui_splitter_container,
       splitter_2  
TYPE REF TO cl_gui_splitter_container,
       container   
TYPE REF TO cl_gui_custom_container,
       container_1 
TYPE REF TO cl_gui_container,
       container_2 
TYPE REF TO cl_gui_container,
       container_3 
TYPE REF TO cl_gui_container.
DATA : it_mara     TYPE TABLE OF mara,
       it_makt     
TYPE TABLE OF makt,
       it_mseg     
TYPE TABLE OF mseg,
       c_container 
TYPE scrfname VALUE 'ccontainer',
       grid1       
TYPE REF TO cl_gui_alv_grid,
       grid2       
TYPE REF TO cl_gui_alv_grid,
       grid3       
TYPE REF TO cl_gui_alv_grid.

**fetching the three tables
SELECT FROM  mara INTO TABLE it_mara UP TO 100 ROWS.
SELECT FROM  makt INTO TABLE it_makt UP TO ROWS.
SELECT FROM  mseg INTO TABLE it_mseg UP TO ROWS.

START-OF-SELECTION.
  
CALL SCREEN 9000.

*&---------------------------------------------------------------------*
*&      Module  STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_9000 OUTPUT.

  
SET PF-STATUS 'ZSTATUS'.
*  SET TITLEBAR 'xxx'.

  
PERFORM create_splitter_1.
  
PERFORM create_splitter_2.
  
PERFORM display_grid1.
  
PERFORM display_grid2.
  
PERFORM display_grid3.

ENDMODULE.                 " STATUS_9000  OUTPUT

*&---------------------------------------------------------------------*
*&      Form  CREATE_SPLITTER_1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_splitter_1 .

  
CREATE OBJECT container
    
EXPORTING
*     PARENT         =
      container_name 
'CCONTAINER'.

  
CREATE OBJECT splitter_1
    
EXPORTING
      parent  
container
      
rows    1
      columns 
2.

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

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

ENDFORM.                    " CREATE_SPLITTER_1
*&---------------------------------------------------------------------*
*&      Form  CREATE_SPLITTER_2
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_splitter_2 .

  
CREATE OBJECT splitter_2
    
EXPORTING
      parent  
container_2
      
rows    2
      columns 
1.

  
CALL METHOD splitter_2->get_container
    
EXPORTING
      row       
1
      column    
1
    RECEIVING
      container 
container_2.

  
CALL METHOD splitter_2->get_container
    
EXPORTING
      row       
2
      column    
1
    RECEIVING
      container 
container_3.

ENDFORM.                    " CREATE_SPLITTER_2
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_GRID1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display_grid1 .


  
CREATE OBJECT container
    
EXPORTING
      container_name 
c_container.

  
CREATE OBJECT grid1
    
EXPORTING
      i_parent 
container_1.

  
CALL METHOD grid1->set_table_for_first_display
    
EXPORTING
      i_structure_name 
'MARA'
    
CHANGING
      it_outtab        
it_mara.

ENDFORM.                    " DISPLAY_GRID1
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_GRID2
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display_grid2 .

  
CREATE OBJECT container
    
EXPORTING
      container_name 
c_container.

  
CREATE OBJECT grid2
    
EXPORTING
      i_parent 
container_2.

  
CALL METHOD grid2->set_table_for_first_display
    
EXPORTING
      i_structure_name 
'MAKT'
    
CHANGING
      it_outtab        
it_makt.

ENDFORM.                    " DISPLAY_GRID2
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_GRID3
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display_grid3 .

  
CREATE OBJECT container
    
EXPORTING
      container_name 
c_container.

  
CREATE OBJECT grid3
    
EXPORTING
      i_parent 
container_3.

  
CALL METHOD grid3->set_table_for_first_display
    
EXPORTING
      i_structure_name 
'MSEG'
    
CHANGING
      it_outtab        
it_mseg.

ENDFORM.                    " DISPLAY_GRID3

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.

  
CASE sy-ucomm.
    
WHEN 'BACK'.
      
LEAVE TO SCREEN 0.
  
ENDCASE.

ENDMODULE.                 " USER_COMMAND_9000  INPUT


Result:





No comments :