Skip to Content
0
Former Member
Jul 24, 2008 at 03:07 PM

turn back to selected row in alv grid

408 Views

Hello experts,

a double click of a row in a alv grid opens a new screen. When I turn back, the alv grid jump to the beginning of the table and not to the selected row (double click). How can I return to the selected row?

I use the function "call function 'REUSE_ALV_GRID_DISPLAY"

and the subroutine user_command.

form user_command using r_ucomm like sy-ucomm
                        rs_selfield type slis_selfield.

  data: rcode like sy-subrc.
  data: zeilen(5) type n.
  data: lines like popuptext occurs 1 with header line .
  data: answer.
  data:  aworg(10) type c.
  data: t_documents like table of acc_doc with header line.
  data: datvo like sy-datum.
  data: datbi like sy-datum.
  data: seltab     type table of rsparams,
        seltab_wa  like line of seltab.
  data: fa_header like zfumbertok.
  data: fa_posi like zfumbertop.
  data: ft_posi like table of fa_posi.
  data: flayout type  slis_layout_alv.

  call function 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
    importing
      es_layout                 = flayout
*   ET_FIELDCAT               =
*   ET_SORT                   =
*   ET_FILTER                 =
*   ES_GRID_SCROLL            =
*   ES_VARIANT                =
*   ET_MARKED_COLUMNS         =
*   ET_FILTERED_ENTRIES       =
*   ET_FIELDCAT_BACKEND       =
*   ES_PRINT                  =
   exceptions
     no_infos                  = 1
     program_error             = 2
     others                    = 3.
....
  case sy-ucomm.
    when '&SEE'.
      read table it_beleg into wa_beleg index rs_selfield-tabindex.
      call function 'ZFUMB_SHOW_REPOSTING'
        exporting
          i_bukrs    = wa_beleg-bukrs
          i_gjahr    = wa_beleg-gjahr
          i_umbnr    = wa_beleg-umbnr
        tables
          t_position = ft_posi
        changing
          c_header   = fa_header
        exceptions
          no_item    = 1
          others     = 2.
      if sy-subrc <> 0.
        message e214.
      endif.
.....
  endcase.


  loop at it_beleg into wa_beleg where bukrs = fa_header-bukrs and
                                       umbnr = fa_header-umbnr and
                                       gjahr = fa_header-gjahr.
    move fa_header-stati to wa_beleg-stati.
    if not wa_beleg-aflag is initial.
      move '1' to wa_beleg-lights.
      move text-l01 to wa_beleg-errtx.
    endif.
    if wa_beleg-stati = 'X'.
      move '0' to wa_beleg-lights.
      move text-l01 to wa_beleg-errtx.
    endif.
    if wa_beleg-stati = 'V'.
      move '3' to wa_beleg-lights.
      move text-l02 to wa_beleg-errtx.
    endif.
    if wa_beleg-stati = 'Z'.
      move '2' to wa_beleg-lights.
      move text-l04 to wa_beleg-errtx.
    endif.
    if wa_beleg-stati = 'B'.
      move '2' to wa_beleg-lights.
      move text-l05 to wa_beleg-errtx.
    endif.
    if wa_beleg-stati = 'C'.
      move '2' to wa_beleg-lights.
      move text-l05 to wa_beleg-errtx.
    endif.
    if wa_beleg-stati = 'S'.
      move '1' to wa_beleg-lights.
      move text-l06 to wa_beleg-errtx.
    endif.
    if not wa_beleg-stord is initial.
      move '3' to wa_beleg-lights.
      move text-l03 to wa_beleg-errtx.
    endif.
    loop at ft_posi into  fa_posi where bukrs eq wa_beleg-bukrs and
                                        umbnr eq wa_beleg-umbnr and
                                        gjahr eq wa_beleg-gjahr and
                                        umpos eq wa_beleg-umpos.
      move: fa_posi-newks to wa_beleg-newks,
            fa_posi-newps to wa_beleg-newps,
            fa_posi-newkt to wa_beleg-newkt,
            fa_posi-grund to wa_beleg-grund,
            fa_posi-rebtr to wa_beleg-rebtr,
            fa_posi-wrbtr to wa_beleg-wrbtr.
      if wa_beleg-shkzg = 'H'.
        wa_beleg-wrshb = 0 - wa_beleg-wrbtr.
      else.
        wa_beleg-wrshb = wa_beleg-wrbtr.
      endif.
    endloop.
    modify it_beleg from wa_beleg.
  endloop.
  rs_selfield-refresh = 'X'.
endform.

thanks

K. Werner