【IT168 技术文章】
我在写ABAP Report时,经常使用如下格式写Report程序,这样思路会更加清楚,在写此文章时,另外加上一些注释,以利于理解!
REPORT ZIEBR140 NO STANDARD PAGE HEADING MESSAGE-ID ZME
LINE-COUNT 90
LINE-SIZE 124.
*&---------------------------------------------------------------------*
*& TABLES:
*&---------------------------------------------------------------------*
*TABLES: ZTEST
*&---------------------------------------------------------------------*
*& CONSTANTS
*&---------------------------------------------------------------------*
*CONSTANTS: PI TYPE I VALUE 124.
*&---------------------------------------------------------------------*
*& Globe variable
*&---------------------------------------------------------------------*
*DATA:LINE TYPE I.
*&---------------------------------------------------------------------*
* TABLE DECLARATION
*&---------------------------------------------------------------------*
*DATA itab type table of wa.
*--------------------------------------------------------------------
* PARAMETER DEFINITION
*--------------------------------------------------------------------
PARAMETERS name(10) type c.
*&---------------------------------------------------------------------*
*& SELECT-OPTIONS
*&---------------------------------------------------------------------*
*************************************(1)报表过程事件Begin***********************
*----------------------------------------------------------------------*
* INITIALIZATION 初始化事件,一般用于字段默认值填充
*----------------------------------------------------------------------*
INITIALIZATION.
* PERFORM FM_INIT_DATA.
*----------------------------------------------------------------------*
*START-OF-SELECTION 选择开始事件
*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------*
* END-OF-SELECTION 选择结束事件,一般用于输出列表
*----------------------------------------------------------------------*
END-OF-SELECTION.
*************************************报表过程事件End************************
*******************************(2)选择屏幕事件Begin*********************************
*&----------------------------------------------------------------------
*& AT SELECTION SCREEN
*&----------------------------------------------------------------------
*AT SELECTION-SCREEN.
*
*Extras:
*1. ... ON psel
*2. ... ON END OF sel
*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
*实例:打开一个文件查询框,选择一个文件的路径.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR name.
************************选择屏幕事件End*********************************
*******************************(3)列表事件Begin******************************
*处理一此报表的交互,如普通列表、ALV等*
*&---------------------------------------------------------------------*
*& AT LINE-SELECTION 行选择控件
*&---------------------------------------------------------------------*
AT LINE-SELECTION.
* PERFORM F_LINE_SELECTION.
*----------------------------------------------------------------------*
*AT USER-COMMAND 用户交控件,可用于实现报表的双击热点等事件
*----------------------------------------------------------------------*
AT USER-COMMAND.
* PERFORM F_USER_COMMAND.
*----------------------------------------------------------------------*
* top-of-page 页眉控件,在每个新页面开始时触发
*----------------------------------------------------------------------*
TOP-OF-PAGE.
* PERFORM F_HEADER.
*----------------------------------------------------------------------*
* End-of-page 页脚控件,在当前页面前触发
*----------------------------------------------------------------------*
END-OF-PAGE.
*******************************列表事件End***********************************
*******************************(4)逻辑数据库事件Begin****************************
*Get node
*Get node LATE
*******************************(4)逻辑数据库事件End******************************