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: 

multiple line selection in ALV

Former Member
0 Kudos

Hi friends,

Can you tell me how to do the following.

I’ve an internal table ITAB with 10 lines of records. It is having 6 columns.

I display this ITAB in ALV using ‘REUSE_ALV_GRID_DISPLAY’.

Now my task is user may select one or more line of records in ALV and I have to move the selected lines of records to A Flat file.

Can you tell me how to do this?.

-

Thanks,

Nash

1 ACCEPTED SOLUTION

Former Member
0 Kudos
1. add one more field checkbox of length 1 to ur final internal tabel
 
2. in ur fieldcatalg add this line
    wa_fcat-fieldname = 'CHECKBOx'.
    wa_fcat-checkbox = 'X'.
    wa_fcat-outputlen = '1'.
    wa_fcat-col_pos = '1'.
    append wa_fcat to it_fcat.
 
3.in ur layout , add this line
   wa_layout-box_fieldname = 'CHECKBOX'.
 
 
4.In th USER_COMMAND subroutine of ur REUSE_ALV_GRID_DISpLAy FM
 
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELFLD TYPE SLIS_SELFIELD.
case p_ucomm.
 
 
Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data
 
when 'SAVE'.

 loop at itab where checbox = 'X'.
*    store these values in another itab
 endloop.

 use GUI_DOWNLOAD to download the entries to excel
.
10 REPLIES 10

Former Member
0 Kudos

Hi Nash

You can do it including a column that have a checkbox

Regards

David

0 Kudos

Yes david but how?

-Nash

0 Kudos

David,

In the field catalog make check_box = 'X'.

My suggestion is if you are displaying the ALV using the OO method, this can be easily handled. There is no need of Check box. Directly we can use the method to get the selected rows.

Regards,

Prakash.

Former Member
0 Kudos

hi,

Check Amit's post in this link

check teh program <b>BCALV_GRID_05</b>

Regards,

Sailaja.

Former Member
0 Kudos
1. add one more field checkbox of length 1 to ur final internal tabel
 
2. in ur fieldcatalg add this line
    wa_fcat-fieldname = 'CHECKBOx'.
    wa_fcat-checkbox = 'X'.
    wa_fcat-outputlen = '1'.
    wa_fcat-col_pos = '1'.
    append wa_fcat to it_fcat.
 
3.in ur layout , add this line
   wa_layout-box_fieldname = 'CHECKBOX'.
 
 
4.In th USER_COMMAND subroutine of ur REUSE_ALV_GRID_DISpLAy FM
 
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELFLD TYPE SLIS_SELFIELD.
case p_ucomm.
 
 
Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data
 
when 'SAVE'.

 loop at itab where checbox = 'X'.
*    store these values in another itab
 endloop.

 use GUI_DOWNLOAD to download the entries to excel
.

Former Member
0 Kudos

Hi Nash

when populating the field catalog use this code for the check box at first column.

CLEAR ls_fieldcat.

ls_fieldcat-tabname = 'I_OUT1'.

ls_fieldcat-fieldname = 'CHECK_BOX'.

ls_fieldcat-col_pos = 1.

ls_fieldcat-seltext_l = 'EDIT'.

ls_fieldcat-checkbox = 'X'.

ls_fieldcat-edit = 'X'.

APPEND ls_fieldcat TO i_fieldcat.

in the internal table add

TYPES : BEGIN OF t_out,

check_box TYPE c,

end of t_out.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = g_repid

i_callback_pf_status_set = 'PF_STATUS_SET'

<b>i_callback_user_command = 'USER_COMMAND'</b>

is_layout = i_layout

it_fieldcat = i_fieldcat

TABLES

t_outtab = i_out2

EXCEPTIONS

program_error = 1

OTHERS = 2.

FORM user_command USING r_ucomm.

CASE R_UCOMM.

WHEN .....

LOOP AT ITAB WHERE CHECKBOX = 'X'.

ENDLOOP

ENDCASE.

ENDFORM.

regards.

David

0 Kudos

hi

Now I did what Chandrasekhar and david mentioned but getting dump error 'field symbol has not been assigned'..i'm not using any field symbol then...?

Nash

0 Kudos

In your fieldcat make sure that the table and field names are capitalized.

This should take care of your error.

Former Member
0 Kudos

Hi Nash

I check it and in some versions you don't neet to put fieldcat part, you can comment it instead of eliminate.

Regards,

David

0 Kudos

Hi all,

thanks for your timely help. points are awarded

-Nash John