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: 

Problem in getting multiple selected rows in ALV

former_member764673
Participant
0 Kudos

Hi,

I m having a report which displays ouput in alv , Multiple row selection is enabled in alv.In ALV there is a delete button in the application toolbar , if i select one or more rows and click delete then all the selected rows should be deleted.

I dont know how to handle multiple selection in ALV and how to retrive the selected rows.

Can anyone please help me out in doing this.

<b>my ALV code is</b>

DATA: fieldcat TYPE lvc_t_fcat,

wa_fieldcat TYPE lvc_s_fcat.

DATA: layout TYPE lvc_s_layo. " layout

zstructure = 'ZREPAIR_ALLTYPES_RECORDS'.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = zstructure

i_bypassing_buffer = 'X'

CHANGING

ct_fieldcat = fieldcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

  • Modify the layout.

layout-zebra = 'X'.

layout-cwidth_opt = 'X'.

layout-sel_mode = 'A'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

i_bypassing_buffer = 'X'

i_callback_program = zrepid

is_layout_lvc = layout

it_fieldcat_lvc = fieldcat[]

i_save = 'U'

is_variant = variant

it_events = events[]

it_event_exit = evexits[]

TABLES

t_outtab = allrecord

EXCEPTIONS

program_error = 1

OTHERS = 2.

Thanks in Advance.

Regards,

Rajanidhi Rajasekeran

6 REPLIES 6

Former Member
0 Kudos

Can you share the code, how you delete for a single record ?

Regards,

Subramanian V.

0 Kudos

Hi,

I am handling this in user command event but i dont know how to get the selected record but i know to get the record which is double clicked. Please see the below attached code and give me suggestions how to handle this.

DATA: events TYPE slis_t_event, " top of page

wa_events TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = events.

READ TABLE events WITH KEY name = slis_ev_user_command

INTO wa_events.

IF sy-subrc IS INITIAL.

wa_events-form = 'USER_COMMAND_ALLRECORD'.

APPEND wa_events TO events.

ENDIF.

FORM user_command_allrecord USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

endform.

Thanks & Regards,

Rajanidhi Rajasekeran.

Former Member
0 Kudos

add a field in allrecord with name selkz type c length 1.

add these lines:

layout-box_fieldname = 'SELKZ'.

layout-box_tabname = 'ITAB'.

LOOP AT gt_fieldcat.

CASE gt_fieldcat-fieldname.

WHEN 'SELKZ'.

gt_fieldcat-no_out = 'X'.

ENDCASE.

MODIFY gt_fieldcat.

ENDLOOP.

add two importing parameters for REUSE_ALV_GRID_DISPLAY_LVC

i_callback_user_command = 'USER_COMMAND'

i_callback_pf_status_set = 'SET_PF_STATUS'

add two new subroutine and in pf-status define your delete

function.

----


  • FORM Set_pf_status *

----


  • ........ *

----


  • --> RT_EXTAB *

----


FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS '001'.

ENDFORM.

----


  • FORM USER_COMMAND *

----


  • ........ *

----


  • --> R_UCOMM *

  • --> RS_SELFIELD *

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

  • I assume that you define fcode as DEL

CHECK r_ucomm = 'DEL'.

CHECK rs_selfield-tabindex > 0.

rs_selfield-refresh = 'X'.

loop at allrecord where selkz eq 'X'.

delete allrecord .

endif.

CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_SET'

EXPORTING

IS_LAYOUT = layout

  • IT_FIELDCAT =

  • IT_SORT =

  • IT_FILTER =

  • IS_GRID_SCROLL =

  • IS_PRINT =

.

ENDFORM.

-


If it helps please give points.

Message was edited by: Fuat Ulugay

0 Kudos

Hi,

Thanks for your answer . My problem is solved.

Thanks again.

Thanks & regards,

Rajanidhi Rajasekeran.

0 Kudos

Hi Rajasekeran,

If an answer from someone helped you or solved your problem, you can say thanks to them by rewarding them with points.

Please do so, so that they will be encouraged to answer more often.

Srinivas

Former Member
0 Kudos

hi, if you call ALV FM with i/p parameter like this:

  I_CALLBACK_USER_COMMAND           = 'FRM_USER_COMMAND'

and code callback subroutine like this:


FORM FRM_USER_COMMAND USING PA_UCOMM TYPE C
                            PA_SELFIELD TYPE SLIS_SELFIELD.
* get the info from PA_SELFIELD

ENDFORM.

PA_SELFIELD will contain the selected row info you need.

thanks