100% found this document useful (1 vote)
6K views4 pages

Row Selection in REUSE

This document discusses how to add row selection functionality to an ALV grid displayed using REUSE_ALV_GRID_DISPLAY. It involves adding a selection field to the output internal table, informing ALV of the selection field name, and processing selected rows in a user command callback. The selection field stores whether each row is selected. Selected rows can then be accessed in the callback based on the value in this field.

Uploaded by

Suresh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
6K views4 pages

Row Selection in REUSE

This document discusses how to add row selection functionality to an ALV grid displayed using REUSE_ALV_GRID_DISPLAY. It involves adding a selection field to the output internal table, informing ALV of the selection field name, and processing selected rows in a user command callback. The selection field stores whether each row is selected. Selected rows can then be accessed in the callback based on the value in this field.

Uploaded by

Suresh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Row Selection in REUSE_ALV_GRID_DISPLAY

By default, when you use function module REUSE_ALV_GRID_DISPLAY to display an ALV, it doesnt come with a Row-Selector. This is fine until you face the need of performing certain task on user-selected rows. Then the user would ask for a RowSelector. In this post, we would see how can we add this Row-Selector i.e. Row Selection Button in an ALV displayed using REUSE_ALV_GRID_DISPLAY and also how to process the selected rows.

First, we would see how to add the Row-Selector / Row selection button to ALV.
Step 1: Add a new character field of length 1 in your output internal table, say SEL. This field is used by ALV to store the information if a particular row is selected or not selected. Suppose, earlier, you were using internal table lt_outtab for your ALV display. So, now, you would need a new output table lt_outtab_new with the above mentioned field. This is how you would do it. DATA: lt_outtab TYPE STANDARD TABLE OF xyz, ls_outtab TYPE xyz. TYPES: BEGIN OF str_xyz,

sel TYPE c. INCLUDE STRUCTURE xyz. TYPES: END OF str_xyz. DATA: lt_outtab_new TYPE STANDARD TABLE OF str_xyz, ls_outtab_new TYPE str_xyz. * Moving your output data from old output table to new output table. LOOP AT lt_outtab INTO ls_outtab. MOVE-CORRESPONDING ls_outtab TO ls_outtab_new. APPEND ls_outtab_new TO lt_outtab_new. ENDLOOP. Step 2: Inform the ALV frameowrk about the name of the newly added field in your output internal table, which ALV should use for storing the information about whether a row is selected or not. You can pass this information to ALV framework by setting attribure BOX_FIELDNAME of the ALV Layout. DATA: ls_layout TYPE slis_layout_alv. ls_layout-box_fieldname = SEL. Step 3: Use REUSE_ALV_GRID_DISPLAY to display your ALV with the new output internal table and updated ALV layout. CALL FUNCTION REUSE_ALV_GRID_DISPLAY EXPORTING i_callback_program = sy-repid i_callback_user_command = USER_COMMAND

is_layout = ls_layout . . TABLES t_outtab = lt_outtab_new. This is all you need to do in order to get the Row-Selector displayed. Next, you need to perform tasks on the selected rows. How to handle this? You can process the selected rows in the callback user command subroutine (in our example, USER_COMMAND) in the callback program (in our example, syrepid) which you pass to FM REUSE_ALV_GRID_DISPLAY through parameters i_callback_user_command & i_callback_program. All the rows which have been selected by user will have the newly added box-field (in our example, SEL) marked as X. You can then have the a logic to perform various tasks on the selected rows based on your needs. FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield. LOOP AT lt_outtab_new INTO ls_outtab_new WHERE sel = X. . . ENDLOOP. ENDFORM. This is how you add a Row-Selector to your ALV and handle the selected rows in your user command callback.

You might also like