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

ALV , selecting a row

Former Member
0 Likes
1,024

Hi

I have a ALV grid with objects. I want to enable the user to select any one row and then be able to clear the entry there by clicking a button . What is the event to initiate this .

Thankyou

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
998

CALL METHOD o_grid->get_selected_rows

IMPORTING

et_index_rows = lt_rows

et_row_no = lt_rowno.

LOOP AT lt_rowno INTO lh_rowno.

READ TABLE t_screen INTO lh_screen INDEX lh_rowno-row_id.

ENDLOOP.

Hi

I have a ALV grid with objects. I want to enable the user to select any one row and then be able to clear the entry there by clicking a button . What is the event to initiate this .

Thankyou

6 REPLIES 6
Read only

Former Member
0 Likes
998

hi

clear means remove the entry from the output. if it is like that select that entry and click on delete option.

if it not like that please explain ur requiremnent.

thanks,

maheedhar.

Read only

Former Member
0 Likes
998

You can determine the selected rows by calling the method get_selected_rows. Once you know what rows have been selected you can delete them from you internal table.

CALL METHOD o_grid->get_selected_rows

IMPORTING

et_index_rows = lt_rows

et_row_no = lt_rowno.

Read only

Former Member
0 Likes
998

Hi

CALL METHOD grid->get_selected_rows

IMPORTING

et_index_rows = t_selected_rows.

To get the selected rows

perform operation on your final internal table (remove the records from your table)

(put this under when sy-ucomm = pushbutton code)

and again call

CALL METHOD grid->set_table_for_first_display

EXPORTING

is_layout = wa_layout

CHANGING

it_outtab = t_outtab[]

it_fieldcatalog = t_fldcat

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

pass the same internal table again to the display

now out put will be refreshed and will not show the deleted records

Regards

Vasu

Read only

0 Likes
998

When I pass the value obtained from the get_selected_rows method , I get a type mismatch error. I am not able to get the value and use it as an index to access my internal table , here is what my code looks like. :

FORM CANCEL_SEL.

DATA : TABIN TYPE I.

DATA T_SELECTED_ROWS TYPE LVC_T_ROW.

DATA LT_ROWNO TYPE LVC_T_ROID .

C_SELQUANT_N TYPE P DECIMALS 3.

CALL METHOD GO_grid->get_selected_rows

IMPORTING

et_index_rows = t_selected_rows

et_row_no = lt_rowno.

*APPEND T_SELECTED_ROWS.

*TABIN = LT_ROWNO.

CLEAR ITAB_W.

READ TABLE ITAB INTO ITAB_W INDEX <b>T_SELECTED_ROWS-ROW_ID.</b>C_SELQUANT = ITAB_W-SEL_QUANT.

C_BALQUANT = ITAB_W-BALQUANT.

C_SELECTED = ITAB_W-F_SELQUANT.

C_SELECTED = C_SELECTED - C_SELQUANT.

C_BALQUANT = C_BALQUANT + C_SELQUANT.

C_SELQUANT = 0.

ITAB_W-SEL_QUANT = C_SELQUANT .

ITAB_W-BALQUANT = C_BALQUANT.

ITAB_W-F_SELQUANT = C_SELECTED.

MODIFY ITAB FROM ITAB_W INDEX T_SELECTED_ROWS.

call method go_grid->refresh_table_display.

ENDFORM.

I have to find the index and pass it to the internal table to be able to update it .The bold portion is what is giving me trouble.

Read only

Former Member
0 Likes
999

CALL METHOD o_grid->get_selected_rows

IMPORTING

et_index_rows = lt_rows

et_row_no = lt_rowno.

LOOP AT lt_rowno INTO lh_rowno.

READ TABLE t_screen INTO lh_screen INDEX lh_rowno-row_id.

ENDLOOP.

Read only

0 Likes
998

Thanks a lot Fred.