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: 

events in alv grid dispaly

Former Member
0 Kudos

Hi,

I have a requirement to select a row in ALV output and perform some action after a button is pressed.

(i.e) i have a release button and after i select a line item in alv output and press on the button ,that item should be released.

so both the events (Selection of line item and pressing of button) should happen together

how can this be achieved.

moreover i should be able to select multiple line items in the alv grid display.how can this be achieved.is it in fieldcatalog level or layout level.

Any pointers to this would be of great help.

Regards,

S.Subasree.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use the FM: REUSE_ALV_GRID_DISPLAY

and in the I_CALLBACK_USER_COMMAND fill the form name "USER_COMMAND".

and create a FORM USER_COMMAND

case sy-ucomm.

when '&REL'. --> Relase.

loop at it_tab into wa_itab where checkbox = 'X'.

or

read table it_tab into wa_itab with key rs_selfield-index = 'X'.

perform the operations.

endloop.

endcase.

ENDFORM.

Regards

Kannaiah

6 REPLIES 6

Former Member
0 Kudos

Hi,

Use the FM: REUSE_ALV_GRID_DISPLAY

and in the I_CALLBACK_USER_COMMAND fill the form name "USER_COMMAND".

and create a FORM USER_COMMAND

case sy-ucomm.

when '&REL'. --> Relase.

loop at it_tab into wa_itab where checkbox = 'X'.

or

read table it_tab into wa_itab with key rs_selfield-index = 'X'.

perform the operations.

endloop.

endcase.

ENDFORM.

Regards

Kannaiah

Former Member
0 Kudos

Hi,

Check the sample code which captures multipe selcted rows

on clicking a button.

FORM sub_user_command USING ucomm TYPE sy-ucomm

sel TYPE slis_selfield.

DATA: ref_grid TYPE REF TO cl_gui_alv_grid.

DATA: count TYPE i ,

i_rows TYPE lvc_t_row .

DATA: lf_row_index TYPE lvc_index ,

i_selected_line_s TYPE lvc_s_row ,

l_vbeln TYPE vbeln .

*then insert the following code in your USER_COMMAND routine...

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.

CASE ucomm.

WHEN 'PDF'.

CALL METHOD ref_grid->get_selected_rows

IMPORTING

et_index_rows = i_rows.

LOOP AT i_rows

INTO i_selected_line_s.

lf_row_index = i_selected_line_s-index.

CLEAR i_selected_line_s.

READ TABLE it_itab

INTO wa_itab

INDEX lf_row_index.

IF sy-subrc EQ 0.

refresh:bdcmsgcoll,

bdcdata.

clear:l_vbeln.

MOVE wa_itab-vbeln TO l_vbeln.

ENDFORM.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_pf_status_set = 'Z_PF_TEST'

i_callback_user_command = 'SUB_USER_COMMAND'

is_layout = ls_layout

it_fieldcat = lt_fieldcat

  • it_sort = lt_sort

TABLES

t_outtab = it_itab.

Regards,

Raj.

Former Member
0 Kudos

To select rows you should have one more field in your fieldcatalog by

wa_fieldcat-pushbutton = 'X'.

Then add a button in ALV menu and in event at user command write logic

form zf_user-command.

if sy-ucomm = 'FCODE'.

READ TABLE itab INTO wa with key pushbutton = 'X'.

<Logic for releasing>

endif.

endform.

hope this is helpful

you can select multiple rows by pressing CTRL and then selecting pushbuttons.

plz reward if useful

vivek

Former Member
0 Kudos

Hi,

Thanks for your reply.

but the pushbutton in the first column is not appearing in my alv output.how can this be obtained ?

Regards,

S.Subasree

0 Kudos

Check the PF status and exclude the standard buttons from the tool bar.

Regards

Kannaiah

Former Member
0 Kudos

the wa_fieldcat declared as type 'slis_fieldcat_alv' does not have a component called pushbutton.