ABAP 的事件

Program type(程序类型)Introductory statement(类型描述)

    1 REPORT(报表)

    M PROGRAM(屏幕程序)

    F FUNCTION-POOL(函数组)

    K CLASS-POOL(类组)

    J CLASS-POOL(接口组)

    T TYPE-POOL(类型池)

There will be different types of events in ABAP.

Events in Dialog Program
PBO - Process Before Output
PAI - Process After Input
POH - Process on Help
POV - Process on Value Request.

Events in Classical Report
INITIALIZATION
AT SELECTION-SCREEN OUTPUT
AT SELECTION-SCREEN
START-OF–SELECTION.
TOP OF PAGE
END OF PAGE
END-OF-SELECTION.

Control Break events related to Internal Tables

AT NEW FIELD
AT END OF FIELD
AT FIRST
AT LAST

Events in Interactive Report
AT USER-COMMAND.
AT LINE-SELECTION
AT PF-FUNCTION KEY

 

There is no mandatory event in a report program. Events are actually used to organize the statements and control the flow of the program. If the program contains no explicitly defined event blocks, all the statements in the program form the entire event block START-OF-SELECTION. ABAP runtime environment automatically introduces a START-OF-SELECTION at the first execution line.

ABAP/4 report programs are event driven programs. Following events are triggered in a report.

LOAD OF PROGRAM. - If propgram is of type 1, M, F, or S; then LOAD-OF-PROGRAM is trigerred first and then INITIALIZATION. The purpose of load of program is to load the program into system memory so that the program can be executed.(当程序类型是report,dialog,fuction pool,subroutine pool时,该事件首先就得触发,使得程序加载进入内存)

INITIALIZATION. - just once.

AT SELECTION-SCREEN OUTPUT. - when there is selection-screen

AT SELECTION-SCREEN. - when user interacts.

START-OF-SELECTION. - when F8.This is the default event in ABAP.

END-OF-SELECTION. - At the end

EVENTS IN A CLASSICAL REPORT:

1. INITIALIZATION: This is triggered when the report is loaded in memory.

2. AT SELECTION-SCREEN OUTPUT: This is triggered when the selection screen is loaded in memory before being displayed.(选择屏幕出现之前触发该事件,对要显示在选择屏幕的屏幕元素进行处理)

3. AT SELECTION-SCREEN/<field> : This event is triggered before leaving the selection screen.(离开选择屏幕之前触发)

4. START-OF-SELECTION: This is the the first and default event for displaying the report. Data retrieval logic is written under this event.(第二个屏幕出现之前触发,常用于list显示之前的逻辑处理)

OUTPUT EVENT(5, 6):
5. TOP-OF-PAGE: This event is triggered every time a new page is started in the list.

6. END-OF-PAGE : This event is triggered every time the list data reaches the footer region of the page.

7. END-OF-SELECTION: This event is triggered after the START-OF-SELECTION is completed.
This event is used when there is use of logical data base in the report. It is triggered in type 1 programs once the logical database completes reading all data i.e. all the selection is finished and before the list processor is started. This statement tells the server that all the database reading is completed and no more data reading is going to take place. END-OF-SELECTION is generally used for the summary/results of reports. In an executable program without logical data base, there is no need to implement the event block END-OF-SELECTION.
After a program is executed by the user, the database is locked when it encounters a START-OF-SELECTION statement and the lock is released when an END-OF-SELECTION statement is encountered (to maintain the consistency). Data selection is done between START-OF-SELECTION and END-OF-SELECTION. Now if we don’t write the END-OF-SELECTION statement, the database will remain locked till the programs get terminated. Hence, the performance will be reduced. So it is always good practice to write END-OF-SELECTION statement after finishing the data selection from database.

EVENTS IN AN INTERACTIVE REPORT:

In addition of the above, the following events are possible in case of Interactive Reports.

1. Top of page during line selection : top of page event for secondary list.

2. At line-selection : evey time user dbl-clicks(F2) on the list data.

3. At pF<key> : function key from F5 to F12 to perform interactive action on the list.

4. At user-command.

==================================================

Finally I want to include one point:
If you debug your report program from the Abap editor screen then it triggers from
1.Initialization,
2.At Selection-screen,
3.Start-of Selection,
4.End-of Selection,
5.Top-of-page,
6.End-of-page.

But if you debug from the selection-screen then it triggers from
1.At Selection-Screen,
2.Start-of-selection,
3.Top-of-page,
4.End-of-page.

 

 

原博文地址:http://blog.chinaunix.net/u1/40527/showart_1079200.html 博主是个资深abaper

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值