输入数据后,点回车,焦点自动换到下一行的该列
code
*&---------------------------------------------------------------------*
*& Report ZLM_ALV_015
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZLM_ALV_015.
* Data Declration
TYPE-POOLS: SLIS.
*
TYPES: BEGIN OF TY_SFLIGHT.
INCLUDE TYPE SFLIGHT.
TYPES: BOX TYPE CHAR1,
END OF TY_SFLIGHT.
*
*
DATA: GT_SFLIGHT TYPE TABLE OF TY_SFLIGHT.
DATA: GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: LT_EVTS TYPE SLIS_T_EVENT,
LA_EVTS LIKE LINE OF LT_EVTS.
*
DATA: GS_REPORT TYPE SY-CPROG,
GS_TITLE TYPE LVC_TITLE.
*
* Start of Selection
START-OF-SELECTION.
*
* Report
GS_REPORT = SY-CPROG.
GS_TITLE = 'Move Cursor to next row by pressing Enter'.
*
* Selection.
SELECT * FROM SFLIGHT
INTO CORRESPONDING FIELDS OF TABLE GT_SFLIGHT UP TO 10 ROWS.
*
* Layout
GS_LAYOUT-EDIT = 'X'.
*
* Event for Data Changed
LA_EVTS-NAME = 'DATA_CHANGED'.
LA_EVTS-FORM = 'GET_DATA_CHANGED'.
APPEND LA_EVTS TO LT_EVTS.
*
* Call ABAP List Viewer (ALV)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_GRID_TITLE = GS_TITLE
I_CALLBACK_PROGRAM = GS_REPORT
I_STRUCTURE_NAME = 'SFLIGHT'
IS_LAYOUT = GS_LAYOUT
IT_EVENTS = LT_EVTS
TABLES
T_OUTTAB = GT_SFLIGHT.
*
*&---------------------------------------------------------------------*
*& Form get_data_changed
*&---------------------------------------------------------------------*
* Here we will get the current cell and than add 1 to it to move
* to next row. Than we will call the method to set the new row
*----------------------------------------------------------------------*
FORM GET_DATA_CHANGED USING RR_DATA_CHANGED
TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
*
DATA: LO_GRID TYPE REF TO CL_GUI_ALV_GRID.
*
DATA: LE_ROW TYPE I,
LE_VALUE TYPE C,
LE_COL TYPE I,
LES_ROW_ID TYPE LVC_S_ROW,
LES_COL_ID TYPE LVC_S_COL,
LES_ROW_NO TYPE LVC_S_ROID.
*
* Get the ALV Object reference
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = LO_GRID.
*
* Get the Current Cell
CALL METHOD LO_GRID->GET_CURRENT_CELL
IMPORTING
E_ROW = LE_ROW
E_VALUE = LE_VALUE
E_COL = LE_COL
ES_ROW_ID = LES_ROW_ID
ES_COL_ID = LES_COL_ID
ES_ROW_NO = LES_ROW_NO.
*
* Set to the next cell
DESCRIBE TABLE GT_SFLIGHT LINES SY-INDEX.
LES_ROW_ID-INDEX = LES_ROW_ID-INDEX 1.
LES_ROW_NO-ROW_ID = LES_ROW_NO-ROW_ID 1.
IF LES_ROW_ID-INDEX LE SY-INDEX.
CALL METHOD LO_GRID->SET_CURRENT_CELL_VIA_ID
EXPORTING
IS_ROW_ID = LES_ROW_ID
IS_COLUMN_ID = LES_COL_ID
IS_ROW_NO = LES_ROW_NO.
ENDIF.
ENDFORM. "get_data_changed