AT LINE SELECTION的用法

用AT LINE SELECTION在报表的输出时,点击某行响应相应的事件和位置

*&---------------------------------------------------------------------*
*& Report  ZTEST_LINE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT  ZTEST_LINE.

*AT LINE-SELECTION用于在报表输出时,点击某行时所产生的操作,响应的位置在整行。

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."HIDE的功能是抓取某个field在某行中的值,与sy-linno相关
ENDDO.
AT LINE-SELECTION.
  WRITE:SQUARE,CUBE.

*如果在应用中希望只是对某个field,点击有效,而不是整行
DATA:L_MBLNR LIKE MKPF-MBLNR.
DATA:I_MKPF LIKE TABLE OF MKPF WITH HEADER LINE.
START-OF-SELECTION.
FORMAT HOTSPOT."鼠标呈现手型
SELECT MBLNR MJAHR
  INTO CORRESPONDING FIELDS OF TABLE I_MKPF
  FROM MKPF.
  ULINE (29).
WRITE:/1 '|',2 'MBLNR',20 '|',21 'MJAHR',29 '|'.
LOOP AT I_MKPF.
    ULINE /(29).
    WRITE:/1 '|',2 I_MKPF-MBLNR,20 '|',21 I_MKPF-MJAHR,29 '|'.
ENDLOOP.
    ULINE /(29).
AT LINE-SELECTION.
  GET CURSOR FIELD I_MKPF-MBLNR VALUE L_MBLNR.
  READ TABLE I_MKPF WITH KEY MBLNR = L_MBLNR.
  IF SY-SUBRC = 0.
     SET PARAMETER ID 'MBN' FIELD I_MKPF-MBLNR.
     CALL TRANSACTION 'MB03' AND SKIP FIRST SCREEN.
  ENDIF.

你可能感兴趣的:(AT-LINE,ALV)