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

code for alv grid row selection to internal table.

Former Member
0 Likes
419

hi,

my requirement is i have to select rows in the alv grid output and move them to the internal table.

give provide an example code for this requirement

3 REPLIES 3
Read only

abapdeveloper20
Contributor
0 Likes
391

Hi,

Selecting rows means in what way??? Will check box is okay for you???

Read only

Former Member
0 Likes
391

Hi,

For your final internal table add one more field as flag.

Ex: flag TYPE c.

DATA : BEGIN OF i_zaw_pol_plan.

DATA : flag TYPE c.

INCLUDE STRUCTURE zaw_pol_plan.

DATA : END OF i_zaw_pol_plan.

DATA : ws_repid LIKE sy-repid,

gs_layout TYPE slis_layout_alv,

i_fieldcat TYPE slis_t_fieldcat_alv.

After passing the data to your final internal table and creation of field catelog..

ws_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = ws_repid

i_callback_pf_status_set = 'GUI_STAT'

i_callback_user_command = 'STAT'

is_layout = gs_layout

it_fieldcat = i_fieldcat[]

TABLES

t_outtab = i_zaw_pol_plan.

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

DATA selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN 'MOVE' .

LOOP AT i_zaw_pol_plan WHERE flag EQ c_x.

MOVE-CORRESPONDING i_zaw_pol_plan TO i_itab.

APPEND i_itab.

CLEAR i_itab.

ENDLOOP.

ENDCASE.

ENDFORM.

Pls. reward if useful.....

Read only

Former Member
0 Likes
391

You can di like below in the user command form of your prog.

form zf_user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

case r_ucomm.

when 'SAVE'.

read table it_mat index rs_selfield-tabindex into wa_mat.

append wa_mat to it_mat2.

that is you just need to read your internal table that you are passing to alv from index " rs_selfield-tabindex " .

reward if helpful