12-20-2006 1:25 AM
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
12-20-2006 1:41 AM
I think that this container should be g_custom_container1.
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_container1. "<- Right Here
Regards,
Rich Heilman
12-20-2006 1:41 AM
I think that this container should be g_custom_container1.
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_container1. "<- Right Here
Regards,
Rich Heilman
12-20-2006 1:51 AM
Hi Rich,
CREATE OBJECT grid11
EXPORTING i_parent = g_custom_container1. "<- Right Here
Now i changed code to,
MODULE pbo_200 OUTPUT.
SET PF-STATUS 'MAIN100'.
IF g_custom_container1 IS INITIAL.
CREATE OBJECT g_custom_container1
EXPORTING container_name = g_container2.
CREATE OBJECT grid11
EXPORTING i_parent = g_custom_container1.
CALL METHOD grid11->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_outtab = gt_sflight.
ENDIF.
ENDMODULE. "PBO OUTPUT
Still it doesnt work. Is there any other procedure to achieve this result.? Thanska for your time.
12-20-2006 1:57 AM
Ok, next problem is that you are calling both screens one after the other.
CALL SCREEN 100.
CALL SCREEN 200.
Which means that the first grid will come on the first screen, when it is displayed, you hit the BACK button and exit the program without calling screen 200. do you want to show both on one screen? If so, you need to put both containers on screen 100.
Regards,
Rich Heilman
12-20-2006 2:27 AM
Hi Rich,
<b>Thanks a Lot for your Quick help</b>.Your hint resolved my problem.
i want 2 ALV's Each on diffrent screens. So i created 2 containers on 2 different screen i.e. 100,200.
I activate the UP/NEXT keys in the application tool bar status . When i run the prog as normal this will display the first ALV , when they hit next(Function code :NEXT) arrow from toolbar im calling screen 200, which will display the second ALV. Thats wat i want.Thanks again.
I Pasted the sample code here (hoping that it may help others).
PROGRAM zsgppi_opac_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 *
*---------------------------------------------------------------------*
*JUST insert SOME DATA for testing.
sflight-carrid = '1000'.
DO 40 TIMES.
sflight-carrid = sflight-carrid + 1.
INSERT sflight.
ENDDO.
SELECT * FROM sflight INTO TABLE gt_sflight.
*call the First ALV
CALL 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
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE pai INPUT.
* to react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
*user pressed next arrow from application toolbar from 1st ALV.
WHEN 'NEXT'.
PERFORM next_program.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN OTHERS.
* do nothing
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE pbo_200 OUTPUT.
SET PF-STATUS 'MAIN100'.
IF g_custom_container1 IS INITIAL.
CREATE OBJECT g_custom_container1
EXPORTING container_name = g_container2.
CREATE OBJECT grid11
EXPORTING i_parent = g_custom_container1.
CALL METHOD grid11->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_outtab = gt_sflight.
ENDIF.
ENDMODULE. "PBO OUTPUT
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE pai_200 INPUT.
* to react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
*user pressed up arrow from application toolbar from 2nd alv.
WHEN 'UP'.
PERFORM up_program.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN OTHERS.
* do nothing
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM exit_program.
LEAVE PROGRAM.
ENDFORM. "EXIT_PROGRAM
*&---------------------------------------------------------------------*
*& Form up_program
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM up_program .
*DISPLAY fIRST alv
CALL SCREEN 100.
ENDFORM. " up_program
*&---------------------------------------------------------------------*
*& Form NEXT_program
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM next_program.
*DISPLAY SECOND alv
CALL SCREEN 200.
ENDFORM. "NEXT_program