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: 

When I double-click on the ALV, how to get the index id?

Former Member
0 Kudos
547

Hi.

When I double click one record on the ALV grid, the parameter 'rs_selfield-tabindex' doesn't return the index in my output table.

It seems that rs_selfield-tabindex returns the rowno as displayed and not the corresponding rowno of my output table. Resulting in wrong values after the grid is sorted.

How can I determine the row in my table from the selected cell in the grid?

5 REPLIES 5

Former Member
0 Kudos
98

Hi,

rs_selfield-tabindex returns the row no on which u have double clicked. after geting tt rs_selfield-tabindex u have to read the o/p table with tat index = rs_selfield-tabindex. you will get the whole record

Former Member
0 Kudos
98

HI, Shetty.

Can you tell me what's name of o/p table? my output table name is it_data.

0 Kudos
98

Hi,

Do the things like this way:

READ TABLE IT_DATA INTO WA_DATA INDEX RS_SELFIELD-TABINDEX. "This gives you the record for that selected row

I am providing one example for your help:

*SET PF-STATUS 'YSTATUS'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
is_layout = gs_layout
i_buffer_active = 'X'
it_fieldcat = ct_fieldcat[]
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_DEFAULT = 'X'
I_CALLBACK_USER_COMMAND = 'HANDLE_USER_COMMAND'
i_save = 'A'
TABLES
t_outtab = lt_purchase[].
* EXCEPTIONS
* program_error = 1
* OTHERS = 2.

FORM HANDLE_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.

CASE R_UCOMM.

WHEN '&IC1'.

IF RS_SELFIELD-FIELDNAME = 'MATNR'.
CLEAR : wa_purchase.
READ TABLE lt_purchase INTO wa_purchase INDEX RS_SELFIELD-TABINDEX.

if wa_purchase-matnr is NOT INITIAL.
SET PARAMETER ID: 'MAT' FIELD wa_purchase-matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
endif.
endform

May it helps you.

Regards.

DS

0 Kudos
98

SLIS_SELFIELD

thanks

Former Member
0 Kudos
98

sovled,

1. the internal table must be gobal variant.

2. the code 'read table index tabindex' must in subroutine 'user_command'.