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

Problem with tabindex on ALV user_command.

Former Member
0 Likes
1,759

Hi experts,

We have an issue with 'REUSE_ALV_GRID_DISPLAY' when calling the user command.

We want to list some data refering to the selected line (with double click) and we use p_selfield-tabindex to know the selected line, no problem with this.

The problem comes when the user changes the order of the alv whit the button. Then, the p_selfield-tabindex variable gets confused and referes to a wrong line.

Can someone help me with this please?

Thanks!!!

8 REPLIES 8
Read only

Former Member
0 Likes
1,242

Hi,

Check that the internal table from which ur reading against the tabindex ( p_selfield-tabindex ) and the internal table which is used in ALV display are same i think you are reading another internal table in usercommand and displaying another internal table . This is the problem i think.

Regards,

Madhukar Shetty

Read only

0 Likes
1,242

We have checked it, it's the same. When not ordering it works correctly, it fails when we change the original order (ordering by date or another field)

Read only

0 Likes
1,242

Hi,

I think this is the only problem , as i have also faced the same issue, because once u sort the internal table is also sorted.

Have checked after sort the ALV and then u double click on line item, have u checked the order of sort in which it is showing in ALV is same in debug of the internal table ?

Regards,

Madhukar Shetty

Read only

0 Likes
1,242

Hello,

I've used another way to get the correct line index:


  DATA:
    lo_grid        TYPE REF TO cl_gui_alv_grid,
    lt_index_rows  TYPE lvc_t_row.


  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
      e_grid = lo_grid.

* Get selected rows
  CALL METHOD lo_grid->get_selected_rows
    IMPORTING
      et_index_rows = lt_index_rows.

I've got no problems with this...

Regards,

Peter

Read only

Former Member
0 Likes
1,242

I'm an Artur coworker. The problem is that itab is not resorting when changing ALV order. So when you double click on visual row '1' you get tabindex = 1, BUT in itab doesn't correspond to that row because is not resorted.

I think the problem will be solved if We could say to 'REUSE_ALV_GRID_DISPLAY' that itab must be resorted when user resort the ALV.

Peter: the problem is that We are using 'REUSE_ALV_GRID_DISPLAY'. (not an option to change it if issue can be solved )

Read only

0 Likes
1,242

Oh, sorry! I omit that you are not using the LVC FM.

Maybe you can solve the problem, if you register the "after" event exit for the sort ucomm. In the callback form, you can use FM reuse_alv_grid_layout_info_get to determine the actual sort settings for the ALV and sort your internal table in the same way.

Sounds complicated to me, but I don't know this ALV display FM. It is just a guess.

Read only

praveen_reddy2
Active Participant
0 Likes
1,242

hi,create ur own custom pf-status or copy the standard status and use the pf status in ur report

through that u will get button in grid.

use this code it will give an idea.

FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM SEL_FIELD TYPE SLIS_SELFIELD.

CASE UCOMM.

WHEN 'DETAILS'. " it is a buttton

  • IF SEL_FIELD-SEL_TAB_FIELD = '1-VBELN'.

READ TABLE IT_VBAK INTO WA_VBAK INDEX SEL_FIELD-TABINDEX.

*

SELECT VBELN PARVW KNREF LAND1 FROM VBPA INTO TABLE IT_VBPA WHERE VBELN = WA_VBAK-VBELN.

  • FOR ALL ENTRIES IN IT_VBAK WHERE VBELN = IT_VBAK-VBELN.

SORT IT_VBPA BY VBELN.

PERFORM FIELDCAT_VBPA.

PERFORM DISPLAY_VBPA.

  • ENDIF.

ENDCASE.

ENDFORM.

FORM PF_STATUS USING EX_TAB TYPE SLIS_T_EXTAB.

SET PF-STATUS 'ZPRK_STATUS' EXCLUDING EX_TAB.

ENDFORM.

Read only

Former Member
0 Likes
1,242

hi friend,

Please find the code and excute that code i thing ur problem will solved.

CLASS lcl_event_receiver DEFINITION.

handle_user_command

FOR EVENT user_command OF cl_gui_alv_grid

IMPORTING e_ucomm.

ENDCLASS.

METHOD handle_user_command.

CASE e_ucomm.

CALL METHOD r_grid->get_selected_rows

IMPORTING

  • ET_INDEX_ROWS =

et_row_no = it_rows.

LOOP AT it_rows INTO wa_rows.

READ TABLE ITAB INTO WA INDEX wa_rows-row_id.

**HERE WE CAN WRITE THE MODIFY CODE****

endloop.

endmethod.

STRAT-OF-SELECTION.

CREATE OBJECT r_container

EXPORTING

container_name = 'CONTAINER_1'

CREATE OBJECT r_grid

EXPORTING

i_parent = r_container

CREATE OBJECT event_receiver1.

  • call method R_GRID->register_edit_event

  • exporting

  • i_event_id = cl_gui_alv_grid=>mc_evt_modifieD.

SET HANDLER event_receiver1->handle_before_user_command FOR r_grid.

Edited by: Muralii on Nov 24, 2010 2:58 PM