Skip to Content
0
Dec 20, 2006 at 01:25 AM

3 ALV GRID Reports in one OO Program

29 Views

Im trying to display 2 alv "GRID" reports in one Program using OO ALV.I created 2 screens with one custom container each. Im calling those 2 screens from my program. But it is displaying only the first alv not displaying the 2nd one.

Can anybody advise whats the procedure to do this way. If u have any code sample i appreciate your help.

Please advise.<b>Thanks a lot for your time.</b>

My sample code looks like this.

PROGRAM zsgppi_osam_rep.
TABLES: sflight.
DATA: ok_code LIKE sy-ucomm,
      gt_sflight TYPE TABLE OF sflight,
      g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
      g_container2 TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT2',
      grid1  TYPE REF TO cl_gui_alv_grid,
      g_custom_container TYPE REF TO cl_gui_custom_container,
            grid11 TYPE REF TO cl_gui_alv_grid,
      g_custom_container1 tyPE REF TO cl_gui_custom_container.
*---------------------------------------------------------------------*
*       MAIN                                                          *
*---------------------------------------------------------------------*
sflight-carrid = '1000'.
INSERT sflight.


sflight-carrid = '2000'.
INSERT sflight.

sflight-carrid = '3000'.
INSERT sflight.

SELECT * FROM sflight INTO TABLE gt_sflight.

CALL SCREEN 100.
CALL SCREEN 200.

*This module is called from screen 100
*---------------------------------------------------------------------*
*       MODULE PBO OUTPUT                                             *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
  SET PF-STATUS 'MAIN100'.
  IF g_custom_container IS INITIAL.
    CREATE OBJECT g_custom_container
           EXPORTING container_name = g_container.
    CREATE OBJECT grid1
           EXPORTING i_parent = g_custom_container.
    CALL METHOD grid1->set_table_for_first_display
      EXPORTING
        i_structure_name = 'SFLIGHT'
      CHANGING
        it_outtab        = gt_sflight.
  ENDIF.
ENDMODULE.                    "PBO OUTPUT
*This module is called from screen 100 PAI event.
*---------------------------------------------------------------------*
*       MODULE PAI INPUT                                              *
*---------------------------------------------------------------------*
MODULE pai INPUT.
*   to react on oi_custom_events:
  CALL METHOD cl_gui_cfw=>dispatch.
  CASE ok_code.
    WHEN 'EXIT'.
      PERFORM exit_program.
    WHEN OTHERS.
*     do nothing
  ENDCASE.
  CLEAR ok_code.
ENDMODULE.                    "PAI INPUT
*This module is called from screen 200 PBO event
*---------------------------------------------------------------------*
*       MODULE PBO OUTPUT                                             *
*---------------------------------------------------------------------*
MODULE pbo_200 OUTPUT.
  SET PF-STATUS 'MAIN100'.
  IF g_custom_container IS INITIAL.
    CREATE OBJECT g_custom_container1
           EXPORTING container_name = g_container2.
    CREATE OBJECT grid11
           EXPORTING i_parent = g_custom_container.
    CALL METHOD grid11->set_table_for_first_display
      EXPORTING
        i_structure_name = 'SFLIGHT'
      CHANGING
        it_outtab        = gt_sflight.
  ENDIF.
ENDMODULE.                    "PBO OUTPUT
*This module is called from screen 200 PAI event
*---------------------------------------------------------------------*
*       MODULE PAI INPUT                                              *
*---------------------------------------------------------------------*
MODULE pai_200 INPUT.
*   to react on oi_custom_events:
  CALL METHOD cl_gui_cfw=>dispatch.
  CASE ok_code.
    WHEN 'EXIT'.
      PERFORM exit_program.
    WHEN OTHERS.
*     do nothing
  ENDCASE.
  CLEAR ok_code.
ENDMODULE.                    "PAI INPUT

*---------------------------------------------------------------------*
*       FORM EXIT_PROGRAM                                             *
*---------------------------------------------------------------------*
FORM exit_program.
*  CALL METHOD G_CUSTOM_CONTAINER->FREE.
*  CALL METHOD CL_GUI_CFW=>FLUSH.
  LEAVE PROGRAM.
ENDFORM.                    "EXIT_PROGRAM