ABAP报表开发:常见报表程序框架

以下是常见报表程序框架,部分模块在实际使用中可以删减:
一、 顶部备注

*&---------------------------------------------------------------------*
*& Program Name     :                                                  *
*& Title            :                                                  *
*& Module Name      : Human Resources                                  *
*& Sub-Module       : PY                                               *
*& Author           :                                                  *
*& Create Date      :                                                  *
*& Program Type     : Report                                           *
*& Change Request   :                                                  *
*& HR Report Categ. :                                                  *
*& SAP Release      :                                                  *
*&---------------------------------------------------------------------*

二、 变量声明

*----------------------------数据声明部分:------------------------------------*
"INCLUDE z_x_xxxxxtop .                   " TOP 子程序,用来声明全局变量(可无)
TABLES: XXX.                              "与屏幕字段相关时才声明
DATA: x.
DATA: BEGIN OF xx OCCURS 0,               "带表头行的内表
       "......
      END OF xx.
DATA itab LIKE TABLE OF xx WITH HEADER LINE.

*声明 Selection-screen 变量*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.   "带边框和标题

SELECTION-SCREEN SKIP.
SELECT-OPTIONS: s_bukrs  FOR  XXX-bukrs MEMORY ID  buk.
PARAMETERS:     p_date   LIKE sy-datum   DEFAULT sy-datum.
PARAMETERS p_file  LIKE rlgrap-filename OBLIGATORY DEFAULT 'D:\个人所得税报告表.xls'.

SELECTION-SCREEN  END  OF BLOCK b1.

三、 主程序处理

*----------------------------主程序部分:------------------------------------*
*初始化
INITIALIZATION.
  "PERFORM  ini_selection_screen.          " 初始化选择屏上的变量

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file. "选择屏幕字段操作(可用于创建字段帮助)
  "PERFORM sub_file_select USING p_file.   "选择本地文件

AT SELECTION-SCREEN.
  "PERFORM  ini_data.                      " 初始化全局变量
  "perform frm_auth_check.                 "权限校验

*数据处理
START-OF-SELECTION.
  "PERFORM  precess_data.                  "主要数据处理逻辑

AT LINE-SELECTION.   
  "PERform  PRECESS_LINE_SELECTED.         " 行选择时的处理

AT USER-COMMAND.
  "PERform  PRECESS_USER_COMMAND.          " 用自定义命令按钮时的处理
  
TOP-OF-PAGE.
  "PERform  PAGE_HEADER.                   " 页眉

END-OF-PAGE.
  "PERform  PAGE_FOOT.                     " 页脚

*结果展示
END-OF-SELECTION.
  "PERFORM  disp_itab                      "内表数据导出或展示

你可能感兴趣的:(ABAP报表开发:常见报表程序框架)