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: 

How to preselect all rows before displaying ALV report

Former Member
0 Kudos

I would like to select all rows before sending ALV Grid Display. User then can unselect couple of rows for further processing. How do I do that ?. Im using Method grid1->SET_TABLE_FOR_FIRST_DISPLAY for ALV Report Display. Any help appreciated.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Ok,

I've started the editor and check my code. I made few small mistakes (like with this exporting/importing), here's the sample - correctly working - code:



DATA: it_selected TYPE lvc_t_row,
      wa_selected TYPE lvc_s_row,
      wa_sflight TYPE sflight,
      ltp_layout TYPE lvc_s_layo.

     SELECT *
       FROM sflight
       INTO TABLE gi_sflight.

ltp_layout-stylefname = 'CELLTAB'.
ltp_layout-sel_mode = 'A'.

LOOP AT gi_sflight INTO wa_sflight.
      wa_selected-index = sy-tabix.
      APPEND wa_selected TO it_selected.
ENDLOOP.

*   * Load data into the grid and display them
     CALL METHOD go_grid->set_table_for_first_display
       EXPORTING i_structure_name = 'SFLIGHT'
                 is_layout            = ltp_layout
                 i_save = 'A'
       CHANGING  it_outtab        = gi_sflight.


CALL METHOD go_grid->set_selected_rows
      EXPORTING
        it_index_rows = it_selected.

This time it is 100% correct.

Edited by: Marcin Cudo on Apr 11, 2010 2:13 AM

6 REPLIES 6

Former Member
0 Kudos

Hi,

you can use method set_selected_rows of class cl_gui_alv_grid. Just loop through the the table you are going to display and add corresponding index to the work area, then append it to it_index_rows table.


DATA: it_selected TYPE lvc_t_row,
            wa_selected TYPE lvc_s_row.

LOOP AT it_your_table  TRANSPORTING NO FIELDS.
      wa_index-index = sy-tabix.
      APPEND wa_selected TO it_selected.    
ENDLOOP.

CALL METHOD grid1->set_selected_rows
      IMPORTING
        it_index_rows = it_selected.

I didn't test it right now, but i suppose it should work fine.

0 Kudos

Thanks a lot for the reply. When should I call this method ?. before calling grid1->SET_TABLE_FOR_FIRST_DISPLAY or after ?

Former Member
0 Kudos

Sreenivas, I really think it wouldn't take much time to just copy and paste this code before and after method set_table_for_first_display, activate it and check which one is giving the correct result

0 Kudos

I tried both before and after still no luck. But Im sure set_selected_rows might do the trick. I think we need to export params rathan import. What do you think ?

Former Member
0 Kudos

Ok,

I've started the editor and check my code. I made few small mistakes (like with this exporting/importing), here's the sample - correctly working - code:



DATA: it_selected TYPE lvc_t_row,
      wa_selected TYPE lvc_s_row,
      wa_sflight TYPE sflight,
      ltp_layout TYPE lvc_s_layo.

     SELECT *
       FROM sflight
       INTO TABLE gi_sflight.

ltp_layout-stylefname = 'CELLTAB'.
ltp_layout-sel_mode = 'A'.

LOOP AT gi_sflight INTO wa_sflight.
      wa_selected-index = sy-tabix.
      APPEND wa_selected TO it_selected.
ENDLOOP.

*   * Load data into the grid and display them
     CALL METHOD go_grid->set_table_for_first_display
       EXPORTING i_structure_name = 'SFLIGHT'
                 is_layout            = ltp_layout
                 i_save = 'A'
       CHANGING  it_outtab        = gi_sflight.


CALL METHOD go_grid->set_selected_rows
      EXPORTING
        it_index_rows = it_selected.

This time it is 100% correct.

Edited by: Marcin Cudo on Apr 11, 2010 2:13 AM

0 Kudos

You THE man. Thanks a lot.