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 Grid

Former Member
0 Likes
913

I need to be able to select multiple rows on ALV grid. Not using classes, using REUSE_ALV_GRID_DISPLAY hence using layout as SLIS_LAYOUT_ALV that does not have field like SEL_MODE.

Your help will be very useful.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
876

Hi reshmi,

1. To get a taste of it,

just copy paste this program.

2. It will display alv (t001)

It will show CHECKBOXES (besides every row)

(In GRID it shows record selectors, instead of

checkbox, just like excel)

(we can select multiple rows,

by using Ctrl key)

TICK some rows,

and DOUBLE-CLICK ON any row.

3. It will display all the row numbers which have been checked/ticked.

4.

report abc.

TYPE-POOLS : slis.

*----


Data

DATA : BEGIN OF itab OCCURS 0.

INCLUDE STRUCTURE t001.

DATA : flag tyPE c,

END OF itab.

DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : alvly TYPE slis_layout_alv.

*----


Select Data

SELECT * FROM t001 INTO TABLE itab.

*------- Field Catalogue

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'ITAB'

i_inclname = sy-repid

CHANGING

ct_fieldcat = alvfc

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

*----


Display

alvly-box_fieldname = 'FLAG'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

it_fieldcat = alvfc

i_callback_program = sy-repid "<-------Important

i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important

is_layout = alvly

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

*----


  • CALL BACK FORM

*----


FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE

slis_selfield.

data : msg(100) type c.

LOOP AT itab.

if itab-flag = 'X'.

msg = sy-tabix.

condense msg.

concatenate 'Row Number ' msg ' ' into msg

separated by space.

message msg type 'I'.

endif.

ENDLOOP.

ENDFORM. "ITAB_user_command

regards,

amit m.

I need to be able to select multiple rows on ALV grid. Not using classes, using REUSE_ALV_GRID_DISPLAY hence using layout as SLIS_LAYOUT_ALV that does not have field like SEL_MODE.

Your help will be very useful.

Thanks.

7 REPLIES 7
Read only

Former Member
0 Likes
877

Hi reshmi,

1. To get a taste of it,

just copy paste this program.

2. It will display alv (t001)

It will show CHECKBOXES (besides every row)

(In GRID it shows record selectors, instead of

checkbox, just like excel)

(we can select multiple rows,

by using Ctrl key)

TICK some rows,

and DOUBLE-CLICK ON any row.

3. It will display all the row numbers which have been checked/ticked.

4.

report abc.

TYPE-POOLS : slis.

*----


Data

DATA : BEGIN OF itab OCCURS 0.

INCLUDE STRUCTURE t001.

DATA : flag tyPE c,

END OF itab.

DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : alvly TYPE slis_layout_alv.

*----


Select Data

SELECT * FROM t001 INTO TABLE itab.

*------- Field Catalogue

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'ITAB'

i_inclname = sy-repid

CHANGING

ct_fieldcat = alvfc

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

*----


Display

alvly-box_fieldname = 'FLAG'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

it_fieldcat = alvfc

i_callback_program = sy-repid "<-------Important

i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important

is_layout = alvly

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

*----


  • CALL BACK FORM

*----


FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE

slis_selfield.

data : msg(100) type c.

LOOP AT itab.

if itab-flag = 'X'.

msg = sy-tabix.

condense msg.

concatenate 'Row Number ' msg ' ' into msg

separated by space.

message msg type 'I'.

endif.

ENDLOOP.

ENDFORM. "ITAB_user_command

regards,

amit m.

Read only

0 Likes
876

Thanks for the reply. I should be able to select any line not necessarily in order. Like if the output has 10 lines, i should eba ble to select 1,6 and 9 line. Right now i am able to select all or just one row or rows adjacent to each other.

Your answer will be helpful.

Read only

0 Likes
876

Hi again,

1. U are right,

2. we can do that , its just a matter of operation.

3. Press Ctrl and Click on 2nd row.

(Do not leave the Ctrl key)

Now click on 5th row,

now click on 9th row.

... like this.

regards,

amit m.

Read only

0 Likes
876

Hi,

Are you holding ctrl while selecting?

Read only

0 Likes
876

Thanks, it worked )

I was using Shift instead of Ctrl. Will allocate full points to the 2 Amits.

Read only

amit_khare
Active Contributor
0 Likes
876

Hi Rashmi,

If you want to select multiple rows from anALV Grid you need to inser one more field in your table as type C and its outlook will be Box type on the grid.

Regards,

Amit

Read only

Former Member
0 Likes
876

Hi,

I think the reply posted by Amit would suffice.

Also, if you are new to ALV, then try checking these standard SAP programs.

BCALV_EDIT_01

BCALV_EDIT_02

BCALV_EDIT_03

BCALV_EDIT_04