(1)其实就像一个FORM,所以在这个事件里声明的变量都是局部变量。
(2)根据SY-UCOMM这个系统变量可以判断用户的命令
(3)在这个事件里响应的是屏幕上选择条件中的事件,例如CHECKBOX的选择与否,RADIOBUTTON的选择,LISTBOX的选择等等。
所以分为以下几个方面:
1. ... ON field:在PARAMETER变化时触发的事件,对于选择屏幕某字段输入的PAI事件,当该字段的值被传递给程序时被触发,可以应用于改字段本身的正确性检查,如可系统提示错误,则可以在该字段中重新输入,此时其他元素呈灰色,不接受输入
2. ... ON END OF sel:SELECT-OPTION触发的事件,用于整个选择表输入结束后各行的检查
3. ... ON VALUE-REQUEST FOR psel_low_high:当光标位于某屏幕字段时,选择的帮助(F4)
4. ... ON HELP-REQUEST FOR psel_low_high:当光标位于某屏幕字段时,选择的帮助(F1)
5. ... ON RADIOBUTTON GROUP radi:单选按钮事件,必须进行整体输入检查
6. ... ON BLOCK block:框架的触发事件
7. ... OUTPUT:响应屏幕上的事件,修改选择屏幕的唯一方法
实例:
Event in ABAP report determine process flow of a program. The events are triggered depended on the way the output is generated. They begin after event keyword and end when the next event reached.
Event keyword:
INITIALIZATION.
Occurs when report initialized.
We can use it to check user authorization or prepare output for selection screen.
AT SELECTION-SCREEN OUTPUT :
Occurs each time selection screen about to generated.
We can use it to modify selection screen, for example hide / unhide parameter.
AT SELECTION-SCREEN.
Occurs each user command in selection screen. we can use it to perform checking on user input.
START-OF-SELECTION
Occurs after the standard selection screen has been processed.,
data is read in this event.
END-OF-SELECTION
Occurs after start-of-selection.
TOP-OF-PAGE
Occurs when a new page starts.
Use it for write report header.
END-OF-PAGE
Occurs when a page ends.
Use it for write report footer.
AT LINE-SELECTION
Occurs when the user double-click on report.
AT USER-COMMAND
Occurs when the user push toolbar button.
This is program to demonstrate how to use event properly.
REPORT zt_event LINE-COUNT 10(1). *http://abap-gallery.blogspot.com TABLES: sflight. DATA: BEGIN OF t_report OCCURS 3, carrid LIKE sflight-carrid, connid LIKE sflight-connid, END OF t_report. *begin selection screen PARAMETERS p_datum LIKE sy-datum. PARAMETERS p_check AS CHECKBOX. *end selection screen INITIALIZATION. *begin initialization MOVE sy-datum TO p_datum. *end initialization AT SELECTION-SCREEN. *begin at selection-screen MESSAGE i888(sabapdocu) WITH 'At selection-screen'. IF p_check = 'X'. MESSAGE e888(sabapdocu) WITH 'Clear checkbox'. ENDIF. *end at selection-screen AT SELECTION-SCREEN OUTPUT. *begin at selection-screen output MESSAGE i888(sabapdocu) WITH 'At selection-screen output'. *end at selection-screen output START-OF-SELECTION. *begin start-of-selection. MESSAGE i888(sabapdocu) WITH 'start-of-selection'. SELECT * FROM sflight. MOVE sflight-carrid TO t_report-carrid. MOVE sflight-connid TO t_report-connid. APPEND t_report. ENDSELECT. *end start-of-selection. END-OF-SELECTION. *begin end-of-selection. MESSAGE i888(sabapdocu) WITH 'end-of-selection'. FORMAT COLOR COL_NORMAL. DO 30 TIMES. LOOP AT t_report. WRITE / t_report-carrid. WRITE t_report-connid. ENDLOOP. ENDDO. *end end-of-selection. TOP-OF-PAGE. FORMAT COLOR COL_HEADING. WRITE 'This is header'. END-OF-PAGE. FORMAT COLOR COL_TOTAL. WRITE 'This is footer'. AT LINE-SELECTION. WRITE: / 'Cursor Row:', sy-curow. WRITE: / 'Cursor Col:', sy-cucol.