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

Problem with selecting a row using cl_salv_table

Former Member
0 Likes
4,197

Hi all,

I'm having an issue where my row selection is not being captured. I'm using cl_salv_table and having the codes in SE24. Everything was fine initially when the ALV is displayed. I can somehow select the row for the first time and the row selection is being captured in lt_row. When I click on SAVE (PAI coded in se80), I will call METHOD A (below) which have the code for selecting the line and process something. The issue arise whenever the process is done and the selected row is deleted, selecting another row and clicking SAVE didn't seems to populate lt_row anymore. This is what I don't understand. I construct my ALV in METHOD A, selecting the row & process it in METHOD B & my SAVE button in PAI (SE80).

METHOD A

TRY.

CALL METHOD cl_salv_table=>factory

EXPORTING

r_container = lo_container

container_name = 'CONTAINER'

IMPORTING

r_salv_table = go_alv

CHANGING

t_table = gt_data.

CATCH cx_salv_msg.

ENDTRY.

gr_selection = go_alv->get_selections( ).

gr_selection->set_selection_mode( if_salv_c_selection_mode=>row_column ).

go_alv->display( ).

METHOD B

lt_temp[] = gt_data[].

go_alv->get_metadata( ). --> I can only select the row for the first time after I place this line in. If not, I can't select at all.

lt_row = gr_selection->get_selected_rows( ).

IF lt_row IS NOT INITIAL.

"do something.

ENDIF.

go_alv->set_data(CHANGING t_table = gt_data ).

go_alv->display( ).

PAI (USER_COMMAND)

go_object->METHOD A( ).

Please do help.

5 REPLIES 5
Read only

Former Member
0 Likes
2,252

Alvin,

I see that you have another post too on a similar issue. It is difficult to see through your logic. I hope you have taken a look at the many DEMO programs provided by SAP. I remember a demo program in ALV GRID that outputs the row number of selected row.

Read only

0 Likes
2,252

Fred,

Yes, I did look at the sample. I have no problem if I code my program in 1 piece (all via SE80). But now my requirement is to separate the program logic (needs to code in SE24) from the screen logic (SE80). I'm not very familiar with OO s o there might be a link or certain instantiation which I have missed.

Read only

0 Likes
2,252

I am sorry if I am stating the obvious, I hope you have defined local classes to handle the alv changes, and used set handler <.....->handle_data_changed> for the alv.

Read only

0 Likes
2,252

Hi Fred,

I'm using the new object model cl_salv_table. So, I don't need the event.

Read only

0 Likes
2,252

Yes you do need the event handler. See the event handler method on_user_command in the example program SALV_DEMO_TABLE_SELECTIONS.

Regards,

Rich Heilman