Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

More than two alv grid by using Object Model

Former Member
0 Likes
524

Hi,

Can u pls guide me to display more than two alv grids on a single screen by using <b>Object Model</b>.

Thanks

Raja

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
483

Sure, You can simply have two container in your screen. Check this program.

Create screen 100, and put two custom containers in the screen, call the first one ALV1_CONT and the second ALV2_CONT, them implement this code.



REPORT  zrich_0001.

data: ispfli type table of spfli.
data: isflight type table of sflight.

data: alv1_cont type ref to cl_gui_custom_container.
data: alv2_cont type ref to cl_gui_custom_container.
data: gr_alv1 type ref to cl_salv_table.
data: gr_alv2 type ref to cl_salv_table.

start-of-selection.

select * into table ispfli from spfli.
select * into table isflight from sflight.

call screen 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module STATUS_0100 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

create object alv1_cont
        exporting
             container_name = 'ALV1_CONT'.

CALL METHOD cl_salv_table=>factory
   EXPORTING
*    list_display   = if_salv_c_bool_sap=>false
     r_container    = alv1_cont
*    container_name =
   IMPORTING
     r_salv_table   = gr_alv1
  CHANGING
    t_table        = ispfli.

gr_alv1->display( ).

create object alv2_cont
        exporting
             container_name = 'ALV2_CONT'.

CALL METHOD cl_salv_table=>factory
   EXPORTING
*    list_display   = if_salv_c_bool_sap=>false
     r_container    = alv2_cont
*    container_name =
   IMPORTING
     r_salv_table   = gr_alv2
  CHANGING
    t_table        = isflight.

gr_alv2->display( ).

endmodule.                 " STATUS_0100  OUTPUT

Regards,

Rich Heilman

Sure, You can simply have two container in your screen. Check this program.

Create screen 100, and put two custom containers in the screen, call the first one ALV1_CONT and the second ALV2_CONT, them implement this code.



REPORT  zrich_0001.

data: ispfli type table of spfli.
data: isflight type table of sflight.

data: alv1_cont type ref to cl_gui_custom_container.
data: alv2_cont type ref to cl_gui_custom_container.
data: gr_alv1 type ref to cl_salv_table.
data: gr_alv2 type ref to cl_salv_table.

start-of-selection.

select * into table ispfli from spfli.
select * into table isflight from sflight.

call screen 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module STATUS_0100 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

create object alv1_cont
        exporting
             container_name = 'ALV1_CONT'.

CALL METHOD cl_salv_table=>factory
   EXPORTING
*    list_display   = if_salv_c_bool_sap=>false
     r_container    = alv1_cont
*    container_name =
   IMPORTING
     r_salv_table   = gr_alv1
  CHANGING
    t_table        = ispfli.

gr_alv1->display( ).

create object alv2_cont
        exporting
             container_name = 'ALV2_CONT'.

CALL METHOD cl_salv_table=>factory
   EXPORTING
*    list_display   = if_salv_c_bool_sap=>false
     r_container    = alv2_cont
*    container_name =
   IMPORTING
     r_salv_table   = gr_alv2
  CHANGING
    t_table        = isflight.

gr_alv2->display( ).

endmodule.                 " STATUS_0100  OUTPUT

Regards,

Rich Heilman

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
484

Sure, You can simply have two container in your screen. Check this program.

Create screen 100, and put two custom containers in the screen, call the first one ALV1_CONT and the second ALV2_CONT, them implement this code.



REPORT  zrich_0001.

data: ispfli type table of spfli.
data: isflight type table of sflight.

data: alv1_cont type ref to cl_gui_custom_container.
data: alv2_cont type ref to cl_gui_custom_container.
data: gr_alv1 type ref to cl_salv_table.
data: gr_alv2 type ref to cl_salv_table.

start-of-selection.

select * into table ispfli from spfli.
select * into table isflight from sflight.

call screen 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module STATUS_0100 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

create object alv1_cont
        exporting
             container_name = 'ALV1_CONT'.

CALL METHOD cl_salv_table=>factory
   EXPORTING
*    list_display   = if_salv_c_bool_sap=>false
     r_container    = alv1_cont
*    container_name =
   IMPORTING
     r_salv_table   = gr_alv1
  CHANGING
    t_table        = ispfli.

gr_alv1->display( ).

create object alv2_cont
        exporting
             container_name = 'ALV2_CONT'.

CALL METHOD cl_salv_table=>factory
   EXPORTING
*    list_display   = if_salv_c_bool_sap=>false
     r_container    = alv2_cont
*    container_name =
   IMPORTING
     r_salv_table   = gr_alv2
  CHANGING
    t_table        = isflight.

gr_alv2->display( ).

endmodule.                 " STATUS_0100  OUTPUT

Regards,

Rich Heilman

Read only

uwe_schieferstein
Active Contributor
0 Likes
483

Hello Raja

If "Object Model" includes the "old-fashioned" class CL_GUI_ALV_GRID as well then have a look at my sample reports in the following threads:

Regards

Uwe