Application Development 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: 

2 ALV_LIST objects in one screen

Former Member
0 Kudos
160

Hi. I have a question. How to display 2 ALV_LISTs with different data in the screen? It's important that both should have separate sorting options bars. Greetings. P.

1 ACCEPTED SOLUTION

Former Member
38

Hey P,

U can take 2 subscreen areas and call one ALV list in one subscreen and another list in the other subscreen. Even u r going to get separate sorting options bar.

Revert back to me, if any doubts.

Cheers,

jbs

4 REPLIES 4

Former Member
0 Kudos
38

Within a dynpro screen, you can should be able to create two custom containers and then put an ALV grid in each (i.e. an cl_gui_alv_grid in each control)... example below is a very quick cut-and-paste based on SAP's report BCALV_GRID_DEMO - screen 0100 was just adjusted slightly to have two customer controls, ALV_CONTAINER1 & ALV_CONTAINER2... in real life you'd obviously be filling each ALV grid from different data sources.

program zlocal_jc_bcalv_grid_twin.

data:
  ok_code               like sy-ucomm,
  gt_sflight            type table of sflight,
  g_container1          type scrfname value 'ALV_CONTAINER1',
  g_container2          type scrfname value 'ALV_CONTAINER2',
  go_grid1              type ref to cl_gui_alv_grid,
  go_grid2              type ref to cl_gui_alv_grid,
  go_custom_container1  type ref to cl_gui_custom_container,
  go_custom_container2  type ref to cl_gui_custom_container.

start-of-selection.

  select * from sflight
    into table gt_sflight.

  call screen 100.


*----------------------------------------------------------------------*
*  MODULE pbo OUTPUT
*----------------------------------------------------------------------*
module pbo output.

  set pf-status 'MAIN100'.
* ALV1
  if not go_custom_container1 is bound.

    create object go_custom_container1
      exporting
        container_name = g_container1.

    create object go_grid1
      exporting
        i_parent = go_custom_container1.

    call method go_grid1->set_table_for_first_display
      exporting
        i_structure_name = 'SFLIGHT'
      changing
        it_outtab        = gt_sflight.

  endif.
* ALV2
  if not go_custom_container2 is bound.

    create object go_custom_container2
      exporting
        container_name = g_container2.

    create object go_grid2
      exporting
        i_parent = go_custom_container2.

    call method go_grid2->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.
    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

Former Member
0 Kudos
38

hi, you can use custom container for this purpose. And use the class set_table_for_first_display, to display the data inside the container.

Former Member
39

Hey P,

U can take 2 subscreen areas and call one ALV list in one subscreen and another list in the other subscreen. Even u r going to get separate sorting options bar.

Revert back to me, if any doubts.

Cheers,

jbs

former_member235056
Active Contributor
0 Kudos
38

Hi,

The SAP program BALVBT01 provides an example of displaying multiple ALV LIST reports on one page.

Pls reward points.

Regards,

Ameet