*&---------------------------------------------------------------------*
*& Report AT
*& 作成者:張玉剛
*&---------------------------------------------------------------------*
*& 作成日 :2009/08/03
*& 処理概要:AT - Events in lists
*&---------------------------------------------------------------------*
REPORT AT.
*&---------------------------------------------------------------------*
*& AT LINE-SELECTION
*&---------------------------------------------------------------------*
DATA TEXT(20).
START-OF-SELECTION.
PERFORM WRITE_AND_HIDE USING SPACE SPACE.
AT LINE-SELECTION.
CASE TEXT.
WHEN 'List index'.
PERFORM WRITE_AND_HIDE USING 'X' SPACE.
WHEN 'User command'.
PERFORM WRITE_AND_HIDE USING SPACE 'X'.
WHEN OTHERS.
SUBTRACT 2 FROM SY-LSIND.
PERFORM WRITE_AND_HIDE USING SPACE SPACE.
ENDCASE.
CLEAR TEXT.
FORM WRITE_AND_HIDE USING P_FLAG_LSIND P_FLAG_UCOMM.
WRITE / 'SY-LSIND:'.
PERFORM WRITE_WITH_COLOR USING SY-LSIND P_FLAG_LSIND.
TEXT = 'List index'.
HIDE TEXT.
WRITE / 'SY-UCOMM:'.
PERFORM WRITE_WITH_COLOR USING SY-UCOMM P_FLAG_UCOMM.
TEXT = 'User command'.
HIDE TEXT.
IF SY-LSIND > 0.
WRITE / 'PICK here to go back one list level'.
ENDIF.
ENDFORM.
FORM WRITE_WITH_COLOR USING P_VALUE
P_FLAG_POSITIVE.
IF P_FLAG_POSITIVE = SPACE.
WRITE P_VALUE COLOR COL_NORMAL.
ELSE.
WRITE P_VALUE COLOR COL_POSITIVE.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& HIDE
*&---------------------------------------------------------------------*
DATA: square TYPE i,
cube TYPE i.
START-OF-SELECTION.
FORMAT HOTSPOT.
DO 10 TIMES.
square = sy-index ** 2.
cube = sy-index ** 3.
WRITE / sy-index.
HIDE: square, cube.
ENDDO.
AT LINE-SELECTION.
WRITE: square, cube.
*&---------------------------------------------------------------------*
*& AT USER-COMMAND
*&---------------------------------------------------------------------*
DATA: NUMBER1 TYPE I VALUE 20,
NUMBER2 TYPE I VALUE 5,
RESULT TYPE I.
START-OF-SELECTION.
WRITE: / NUMBER1, '?', NUMBER2.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'ADD'.
RESULT = NUMBER1 + NUMBER2.
WHEN 'SUBT'.
RESULT = NUMBER1 - NUMBER2.
WHEN 'MULT'.
RESULT = NUMBER1 * NUMBER2.
WHEN 'DIVI'.
RESULT = NUMBER1 / NUMBER2.
WHEN OTHERS.
WRITE 'Unknown function code'.
EXIT.
ENDCASE.
WRITE: / 'Result:', RESULT.
*&---------------------------------------------------------------------*
*& AT PFn
*&---------------------------------------------------------------------*
DATA NUMBER TYPE SY-INDEX.
START-OF-SELECTION.
DO 9 TIMES.
WRITE: / 'Row', (2) SY-INDEX.
NUMBER = SY-INDEX.
HIDE NUMBER.
ENDDO.
AT PF8.
CHECK NUMBER IS INITIAL.
WRITE: / 'Cursor was in row', (2) NUMBER.
CLEAR NUMBER.