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: 

ALV OO - get_selected_rows still returns nothing

Former Member
0 Kudos

Hi all,

i am searching for a solution since several weeks . I tried every solution suggestion I found, but nothing helped.

LEAVE TO LIST-PROCESSING.

r_alv->get_metadata( ).

r_alv->get_selections( ).

it_check_rows = r_select->get_selected_rows( ).

The problem is the same like discribed by several other users. If I select row(s) first time everything`s fine, but if I get back from the following Dynpro and try to select rows, method returns an empty table.

Please note that I am NOT using ALV Grid - therefor I have read a lot of solutions

Cheers

Dieter

1 ACCEPTED SOLUTION

Former Member
0 Kudos

so, what are you using? There are demonstration programs for ALV and SALV, named like BCALV* for OO ALV and SALV* for SALV. For instance, SALV_DEMO_TABLE_SELECTIONS gets selections, SALV_TEST_TABLE_SELECTIONS expands further on getting selected cells, etc. Suggest you look at the demo programs, find one that does what you need and model your code to the SAP demo program. Also, there are MANY posts on forums regarding use of these tools.

11 REPLIES 11

Former Member
0 Kudos

so, what are you using? There are demonstration programs for ALV and SALV, named like BCALV* for OO ALV and SALV* for SALV. For instance, SALV_DEMO_TABLE_SELECTIONS gets selections, SALV_TEST_TABLE_SELECTIONS expands further on getting selected cells, etc. Suggest you look at the demo programs, find one that does what you need and model your code to the SAP demo program. Also, there are MANY posts on forums regarding use of these tools.

0 Kudos

Thx for your reply - I took SALV_DEMO_TABLE_SELECTIONS as master and did everything exactly like in this report (btw. I checked other examples before and my coding was not much different) - and I still have this problem. Except one effect changes.

When I select rows the 2nd time I get my Message (i0005), that no row was selected:

LEAVE TO LIST-PROCESSING.

r_alv->get_metadata( ).

r_select = r_alv->get_selections( ).

it_check_rows = r_select->get_selected_rows( ).

IF it_check_rows IS INITIAL.

MESSAGE i005(zhr_of_amu_nacl).

ELSE.

LOOP AT it_check_rows INTO st_check_rows.

....

When I confirm message, I get the details of the row selected first time, although it_check_rows it initial. I checked by debugger, too. It`s initial. So it must be saved anywhere else now.

Seems like the effect described in sap note 832800 - I already checked it. It`s implemented.

Cheers

Dieter

Edit: Oh, the 2nd Screen was called, because CALL SCREEN was outside IF-clause. So it`s still the same effect, but it shows, that initial selection doesn`t get cleared.

Edited by: dieter_a on Mar 8, 2012 11:55 AM

0 Kudos

I did a short test report, just using IT0002 in two ALV to figure out the problem.

Please can someone take a look?

Maybe I did a very silly mistake, but for now, I don`t see it. Still the same effect: Initial Selection doesn`t get cleared.

Edit: -Tag doesn`t work here. If you like take a look to the source code in this txt-file: [get_selected_rows.txt|http://www.byteware.de/uploads/get_selected_rows.txt]

Cheers

Dieter

Edited by: dieter_a on Mar 9, 2012 12:02 PM

0 Kudos

Hi Dieter,

Looks like the middle line is missing in your code :-

r_select = r_alv->get_selections( ).

 r_select->set_selection_mode( if_salv_c_selection_mode=>row_column ).  "This one has to be added

  it_rows = r_select->get_selected_rows( ).

Thanks,

Best regards,

Prashant

0 Kudos

Hi Prashant,

THX for your help. I am sorry - this was not the problem. I defined the selection mode - when defining the first ALV.

Code:

  • Mark-Spalte ********************************************************************

r_select = r_alv->get_selections( ).

r_select->set_selection_Mode(value = 4)

(4 is identical to if_salv_c_selection_mode=>row_column)

Nevertheless I tested it, but it doesn`t help to call Method 2nd time, right before get_selected_rows( ).

Cheers Dieter

Edited by: dieter_a on Mar 9, 2012 3:41 PM

0 Kudos

I figured out following: If I don`t create 1st alv in PBO - I will get the selected rows. But now, factory method of the 2nd alv doesn`t recognize changed table.
I uploaded new version here:

http://www.byteware.de/uploads/get_selected_rows2.txt

0 Kudos

Hi all,

i have shortened the code again. Now there is only one ALV. Instead of calling 2nd ALV, I just added a hard break-point. Clicking details should only fill it_rows. But even this doesn`t work after the initial selection.

http://www.byteware.de/uploads/get_selected_rows3.txt

Cheers Dieter

0 Kudos

Dieter, your method call does not import the selected rows and columns.  I pointed you to SALV demonstration program, SALV_DEMO_TABLE_SELECTIONS, which clearly demonstrates, beginning at line 120, the method statements that result in a return of the rows and columns selected in the SALV display when a user function is selected.  Your code does not return those apparently.  I doesn't matter what your function code is...you just need to detect that AND import the row(s) and/or column(s) selected by your user.  This works perfectly for me, and I believe it will for you, once you have your method calls written correctly.  I don't know why you have that leave to list processing....I'm never inserted that for SALV user command/selection processing.

Here's a sample from my code:

  handle_user_command   for event user_command of cl_gui_alv_grid
            importing e_ucomm,   "don't need the row/column...general statement.

    handle_double_click
            for event double_click of cl_gui_alv_grid
                importing e_row e_column.  "act upon the content of the row/columns selected...

  

my double_click implementation:

read table it_doc into ls_Doc index e_row.  "imported above.
    if ls_doc is not initial.
      perform playback_attached_file using  ls_doc

                                   changing lv_rc.
      if lv_rc is not initial.
        message s016(gr)
            with
          error_message

             display like 'E'.

etc.

and for user command and there could be multiple rows:

   method handle_user_command.

    data: lt_rows   type lvc_t_row,
          ls_rows   type lvc_s_row,
          ls_siudoc type zclttsiudocument,
          lv_rc     type sysubrc.

    case e_ucomm.
      when 'DPL' or 'DEL'. "Display or Delete
        call method siu_grid_001->get_selected_rows
          importing
            et_index_rows = lt_rows.
        loop at lt_rows into ls_rows.
          if ls_rows is not initial.
           read table it_doc into ls_Doc index ls_rows-index.
            if sy-subrc eq 0.

etc.

Message was edited by: David Lindsey

Hi David,

thanks for your reply - after weeks of searching - I figured out my problem, a few minutes ago.

So i will post the answer if anyone else would have the same problem in future. Since I am using ALV OO, there is no method "set_alv_for_first_display".

My mistake was, that I only checked if my container is initial - and NOT if r_alv (TYPE REF TO cl_salv_table) is initial. So factory method was called at every PBO-event.

The solution quite simple:

Don`t call factory method multiple times and get_selected_rows will return the correct results!!!

Cheers

Dieter

0 Kudos

Thank you so much Dieter.

Your comment from almost 10 years ago helped me a lot today.

You rock!

Former Member
0 Kudos

Dieter,

thanks for replying with your solution (not many people do that). It was exactly my problem too.

I was checking to see if my container was initial before creating the objects and it turns out, I was checking the wrong container.

therefore, my get_selected_rows call was coming back empty.