09-10-2009 2:44 PM
I am having a ALV grid using CL_SALV_TABLE class. and its have PF-status button "Display" and user select a line and press "Display" button system will display a PDF document from content server.
The following is the code i am using for getting index of selected row.
My problem is user select a line for the first time i am getting the index, but user select second time i am not getting the index
module user_command_0300 input.
call method cl_gui_cfw=>dispatch.
case ok_code.
when c_hist.
perform f_show_history.
when others.
endcase.
clear ok_code.
endmodule.
then
form f_show_history.
data : p_wa_rows type int4.
data : p_i_rows type salv_t_row.
gr_table->get_metadata( ).
p_i_rows = gr_selections->get_selected_rows( )." Here Its failing in second time. P_I_ROWS showing blank second time
clear: wa_output.
read table p_i_rows into p_wa_rows index 1.
if sy-subrc eq 0.
read table i_output into wa_output index p_wa_rows.
if sy-subrc eq 0.
perform f_display_document.
endif..
endif.
refresh : p_i_rows. clear : p_i_rows.
gr_selections = gr_table->get_selections( ).
gr_selections->set_selected_rows( p_i_rows ).
gr_table->refresh( ).
call method cl_gui_cfw=>set_new_ok_code( new_code = 'REFR' ).
endform. " F_show_history
PS : I don't want to place the button in the ALV application toolbar
a®
09-10-2009 2:54 PM
Hi Dear,
I have some clue regarding your problem but that is in simple Alv not in oops.
declare a first field of your internal table i.e. you are passing to alv as cell type c.
then in layout
add
gs_layout-box_fieldname = 'SEL'.
pass this layout to alv.
then you are able to get exact row number.
LOOP AT gt_gi INTO gs_gi WHERE sel = 'X'.
gs_gi-sel = ' '.
APPEND gs_gi TO gt_gi.
CLEAR gs_gi.
ENDLOOP.
Hope this clue will help you.
Regards,
Vijay
09-10-2009 3:08 PM
Vijay,
Your suggestion will not work. and i am not using field catalog.
Any more suggestions ?
a®
09-10-2009 3:59 PM
Hi,
Maybe:
instead of:
gr_table->get_metadata( ).
p_i_rows = gr_selections->get_selected_rows( )
do:
lv_sel = gr_table->get_selections( ).
lv_row = lv_sel->get_selected_rows( ).
where
DATA: lv_sel TYPE REF TO cl_salv_selections.
DATA: lv_row TYPE salv_t_row.
Best regards
09-10-2009 4:16 PM
Without using
gr_table->get_metadata( ).
I will not get the selected rows info from Frontend
a®
09-10-2009 4:03 PM
Hi Dear ,
In morning I gave you some inputs , repeating the same .
You need to get the index , and after this you have to re-display the ALV and then get index again.
check this will work .
09-10-2009 4:13 PM
Harsh,
You had provide with suggestion to use class CL_GUI_ALV_GRID class , Here i am using OM model SALV class. so your suggestion will not work
a®
09-10-2009 4:23 PM
Sugession :
After ENDCASE statement , in your first block of code .
Please display the resultant internal table again .
it will start working .
09-10-2009 4:28 PM
Harsh,
If you checked my code i given in my first thread, I am refreshing the display
gr_table->refresh( ).
a®
09-10-2009 5:52 PM
09-10-2009 10:10 PM
Hi @rs,
In your form f_show_history, you
refresh : p_i_rows. clear : p_i_rows.
gr_selections = gr_table->get_selections( ).
gr_selections->set_selected_rows( p_i_rows ).
First you clear the p_i_rows table, then you use it to set the selected rows. I'd say setting nothing as selected may result in nothing selected.
May be this is the reason.
Regards,
Clemens
12-17-2020 3:36 PM
Make sure that you don't re-create the table instance at PBO! Only create it once! This was my fault why the rows only work for the first time!
IF lr_table IS INITIAL.
CALL METHOD cl_salv_table=>factory
EXPORTING
r_container = cl_gui_container=>default_screen
IMPORTING
r_salv_table = lr_table
CHANGING
t_table = gt_outtab.
ELSE
lr_table->refresh( ).
ENDIF.