Skip to Content
0
Jun 04, 2009 at 10:39 AM

Getting current selected line contents on an ALV

127 Views

Hi,

I've got an ALV control that I need to get information from.

if the grid is not sorted then all is fine with the code below but as soon as the grid is sorted in descending order and I pick the row I want it all goes to pot - this is because the read is reading from the backend I want the information from the frontend how do I do this?

Basically I need to either get the information from the front end or synchronise the front and backend any ideas?

Many thanks in advance.

Raj

FORM get_selected_row .

* This defines a section of memory.
  FIELD-SYMBOLS: <outtab>     TYPE STANDARD TABLE,
                 <table_line> TYPE ANY,
                 <fld>        TYPE ANY.

  DATA: fname TYPE fieldname.
  DATA: ls_row_id TYPE lvc_s_row.


* Dereference data object.
  ASSIGN gt_outtab->* TO <outtab>.


*
  CALL METHOD gv_alv_obj-grid->get_current_cell
    IMPORTING
      es_row_id = ls_row_id.

  READ TABLE <outtab> ASSIGNING <table_line>
    INDEX ls_row_id-index.


data: l_index_rows type LVC_T_ROW,
      l_row_no type LVC_T_ROID.



CALL METHOD gv_alv_obj-grid->get_selected_rows
  IMPORTING
    et_index_rows = l_index_rows
    et_row_no     = l_row_no.



  CASE gv_main_selection.
    WHEN 'FUNDER'.
      fname = 'FUNDER'.


    WHEN 'FUNDER_TYPE'.
      fname = 'FUNDER_TYPE'.

  ENDCASE.

ENDFORM.                    " GET_SELECTED_ROW