ALV 单元格光标定位

文章转自 http://blog.csdn.net/wren2004/article/details/4036872

在用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

你可能感兴趣的:(SAP,abap,alv)