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 with Mutiple Line selection in ALV using REUSE_ALV_GRID_DISPLAY

abhishek37373
Participant
0 Kudos

Hi Folks,

I am using FM :REUSE_ALV_GRID_DISPLAY for ALV display and want to capture the user selection of multiple line.

Reading various forums i understood that METHOD grid1->get_selected_rows works only for OO ALV and also i don't want to use the Checkbox "SEL" for the user to select as the user have to select each line individually.

Is there any workaround to capture the multiple selection in FM :REUSE_ALV_GRID_DISPLAY

Thanks in Advance.

5 REPLIES 5

rathansekhar
Explorer
0 Kudos

Hi Abhishek,

Pass User_Command to I_CALLBACK_USER_COMMAND.

Example.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

IS_LAYOUT = L_LAYOUT

I_CALLBACK_PF_STATUS_SET = 'STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IT_FIELDCAT = IT_FIELDCAT

TABLES

T_OUTTAB = ITAB

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC = 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*-->R_UCOMM text

*-->RS_SELFIELD text

*----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

DATA: GD_REPID LIKE SY-REPID, "Exists

REF_GRID TYPE REF TO CL_GUI_ALV_GRID.

IF REF_GRID IS INITIAL.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

E_GRID = REF_GRID.

ENDIF.

IF NOT REF_GRID IS INITIAL.

CALL METHOD REF_GRID->CHECK_CHANGED_DATA .

ENDIF.

loop at itab where chk = 'X'.

itab-color = 'C300'.

modify itab index sy-tabix transporting color.

endloop.

RS_SELFIELD-refresh = 'X'.

ENDFORM. "USER_COMMAND

Please go through the below link.

http://scn.sap.com/thread/1178755

Regards,

Rathan.

0 Kudos

Hi Rathan,

Thanks for the reply.Isn't "chk = x" is a check box?

0 Kudos

Hi,

This is not a CHECK box it is like select which will capture the seletced row.

please go through the below link it will halpfull for you.

https://scn.sap.com/thread/1515175

Regards,

Rathan.

akshatrander1990
Explorer
0 Kudos

Hi Abhishek,

Please gothrough this thread.Hope it helps.

http://scn.sap.com/message/5472510#5472510

Regards

Akshat

former_member289261
Active Contributor
0 Kudos


This needs to be done in 2 steps :

1. Enable the grid to be selectable.

    To do this, set field EDIT of layout structure = 'X' while calling the alv fm.

2. At user command get the selected rows using method GET_SELECTED_ROWS.

Here is the sample code :

DATA : itab TYPE TABLE OF mara.

DATA layo TYPE slis_layout_alv.

data : ET_INDEX_ROWS TYPE LVC_T_ROW.

data : ET_ROW_NO TYPE LVC_T_ROID.

SELECT *

INTO TABLE itab

FROM mara UP TO  10 ROWS.

layo-edit  = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING    i_callback_program      = sy-repid 

i_callback_user_command = 'USRCMD' 

i_structure_name        = 'MARA' 

is_layout              = layo

TABLES 

t_outtab                = itab.

FORM usrcmd USING r_ucomm LIKE sy-ucomm                  rs_selfield TYPE slis_selfield.

DATA: gd_repid LIKE sy-repid, "Exists     

ref_grid TYPE REF TO cl_gui_alv_grid.

IF ref_grid IS INITIAL. 

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'   

IMPORTING     

e_grid = ref_grid.

ENDIF.

if REF_GRID is BOUND.

CALL METHOD ref_grid->get_selected_rows 

IMPORTING      et_index_rows = et_index_rows   

et_row_no    = et_row_no .

endif .

ENDFORM.