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: 

turn back to selected row in alv grid

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

Place the below liness in the user_command form.

SELFIELD-COL_STABLE = 'X'.

SELFIELD-ROW_STABLE = 'X'.

FORM USER_COMMAND USING UCOMM TYPE SY-UCOMM  SELFIELD TYPE SLIS_SELFIELD.

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.
"You will be back to where you started , i mean where you clicked
SELFIELD-COL_STABLE  = 'X'.
SELFIELD-ROW_STABLE = 'X'.


ENDFORM.

4 REPLIES 4

former_member188685
Active Contributor
0 Kudos

Place the below liness in the user_command form.

SELFIELD-COL_STABLE = 'X'.

SELFIELD-ROW_STABLE = 'X'.

FORM USER_COMMAND USING UCOMM TYPE SY-UCOMM  SELFIELD TYPE SLIS_SELFIELD.

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.
"You will be back to where you started , i mean where you clicked
SELFIELD-COL_STABLE  = 'X'.
SELFIELD-ROW_STABLE = 'X'.


ENDFORM.

Former Member
0 Kudos

Dear Vijay Babu Dudla,

I saw those fields, but I thought, that they have another function.

Now I know, that both fields control my issue.

Thanks a lot

Kim Werner

former_member216029
Participant
0 Kudos

Hi,

How to do the same if i am using the CL_ALV_GRID class instead of the function module.

I mean i would like to retain the row selections for the ALV grid everytime i navigate away.

Any pointers?

Cheers

Dev

0 Kudos

Check the Method REFRESH_TABLE_DISPLAY

Here one of the parameter talks about the STABLE , ROW STABLE AND COLUMN STABLE.

You pass it 'X' for Row and Column if you want to stay in the same Row and Column.