ALV 单元格光标定位 .

ALV 单元格光标定位

在用ALV做编辑动作时,经常需要用代码来自动定位单元格,实现代码如下:

1. 取当前单元格位置:

  DATA: v_row TYPE i,
        v_col TYPE i.

 CALL METHOD go_ref_alv->get_current_cell
    IMPORTING
      e_row = v_row
      e_col = v_col.

2. 设定光标至目标单元格:

 *&------------------------------------------------------*
*&      Form  set_cursor
*&------------------------------------------------------*
*       text
*-------------------------------------------------------*
FORM set_cursor  USING pi_field pi_row.

  DATA :  wl_is_row_id TYPE lvc_s_row,
          wl_is_column_id  TYPE lvc_s_col,
          wl_is_row_no  TYPE lvc_s_roid.

  wl_is_row_id = pi_row + 1.
  wl_is_column_id = pi_field.
  wl_is_row_no-row_id = pi_row + 1.

  CALL METHOD go_ref_alv->set_current_cell_via_id
    EXPORTING
      is_row_id    = wl_is_row_id           " Row No
      is_column_id = wl_is_column_id        " Column No
      is_row_no    = wl_is_row_no.          " Row No.

ENDFORM.                    " set_cursor

posted @ 2011-08-21 00:16  VerySky  阅读(816)  评论(0)    收藏  举报