ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ZR_FI_002

ZR_FI_002

原创 Linux操作系统 作者:williamzhou 时间:2019-06-17 22:45:06 0 删除 编辑

*===============================基本信息===============================*
* 标题:损益报表
* 创建日期:2004-12-15       
*===============================定    义===============================*

************************************************************************
* 基本代码
************************************************************************
REPORT ZR_FI_002
NO STANDARD PAGE HEADING
LINE-COUNT 80
LINE-SIZE  143
MESSAGE-ID ZFI1.

************************************************************************
* INCLUDE:包含文件
************************************************************************
INCLUDE OLE2INCL.

************************************************************************
* TABLE: 定义TABLE
************************************************************************
TABLES:
  SKAT,         "总帐科目主记录(科目表:说明)
  GLT0,         "总帐科目主记录业务额
  T001,         "公司代码
  RF011Z,       "将资产负债表行项目分配到科目
  RF011Q.       "会计报表项说明文字
************************************************************************
*INTERNAL TABLES
************************************************************************
*定义内表ITABS(作为辅助使用)
  DATA: BEGIN OF ITABS OCCURS 10.
        INCLUDE STRUCTURE GLT0.
        DATA: TAMOUNT LIKE GLT0-HSLVT.
  DATA: END OF ITABS.

*定义本期数内表ITAB
DATA: BEGIN OF ITAB1 OCCURS 0,
        XSSL LIKE GLT0-HSLVT,      "一、主营业务收入
        XSCB LIKE GLT0-HSLVT,      "减:主营业务成本
        XSSJ LIKE GLT0-HSLVT,      "减:主营业务税金及附加

        TOTAL_CSLR LIKE GLT0-HSLVT,"二、主营业务利润
        QTYWLR LIKE GLT0-HSLVT,    "加:其他业务利润

        XSFY LIKE GLT0-HSLVT,      "减:营业费用
        GLFY LIKE GLT0-HSLVT,      "减:管理费用
        CWFY LIKE GLT0-HSLVT,      "减:财务费用

        TOTAL_YYLR LIKE GLT0-HSLVT,"三、营业利润
        TZSY LIKE GLT0-HSLVT,      "加:投资收益
        PTSL LIKE GLT0-HSLVT,      "加:补贴收入
        YYWSL LIKE GLT0-HSLVT,     "加:营业处收入
        YYWZC LIKE GLT0-HSLVT,     "减:营业外支出
        SYDZ LIKE GLT0-HSLVT,      "加:以前年度损益调整

        TOTAL_LRZE LIKE GLT0-HSLVT,"四、利润总额
        SDS LIKE GLT0-HSLVT,       "减:所得税

        TOTAL_JLR LIKE GLT0-HSLVT, "五、净利润
      END OF ITAB1.

*定义本年累计数内表ITAB2
DATA: ITAB2 LIKE ITAB1 OCCURS 10 WITH HEADER LINE.

*定义字符型字段的内表-本期数(用于转换数值的负号显示形式)
DATA: BEGIN OF ITAB1_C OCCURS 0,
        XSSL(20),      "一、主营业务收入
        XSCB(20),      "减:主营业务成本
        XSSJ(20),      "减:主营业务税金及附加

        TOTAL_CSLR(20),"二、主营业务利润
        QTYWLR(20),    "加:其他业务利润

        XSFY(20),      "减:营业费用
        GLFY(20),      "减:管理费用
        CWFY(20),      "减:财务费用

        TOTAL_YYLR(20),"三、营业利润
        TZSY(20),      "加:投资收益
        PTSL(20),      "加:补贴收入
        YYWSL(20),     "加:营业处收入
        YYWZC(20),     "减:营业外支出
        SYDZ(20),      "加:以前年度损益调整

        TOTAL_LRZE(20),"四、利润总额
        SDS(20),       "减:所得税

        TOTAL_JLR(20), "五、净利润
      END OF ITAB1_C.
*定义字符型字段的内表-本年累计数(用于转换数值的负号显示形式)
DATA: ITAB2_C LIKE ITAB1_C OCCURS 10 WITH HEADER LINE.

*定义2005/2期未数据内表
DATA: BEGIN OF ITAB3 OCCURS 10.
        INCLUDE STRUCTURE ZFI03.
DATA: END OF ITAB3.
DATA: BEGIN OF ITAB4 OCCURS 10.
        INCLUDE STRUCTURE ZFI03.
DATA: END OF ITAB4.

*往数据库增加运行日志
  DATA: BEGIN OF IT_ZREPORTLOG OCCURS  0.
    INCLUDE TYPE ZREPORTLOG.
  DATA: END OF IT_ZREPORTLOG.
************************************************************************
* CONSTANTS : 定义常量
************************************************************************

************************************************************************
* TYPE : 定义数据类型
************************************************************************
TYPE-POOLS: SLIS.

************************************************************************
* DATA : 定义变量
************************************************************************
*单据表格上相关坐标值定义
DATA: A1 TYPE I VALUE 0,
      A2 TYPE I VALUE 0,
      A3 TYPE I VALUE 0,
      A4 TYPE I VALUE 0,
      A5 TYPE I VALUE 0.

DATA: B1 TYPE I VALUE 0,
      B2 TYPE I VALUE 0,
      B3 TYPE I VALUE 0,
      B4 TYPE I VALUE 0.

DATA: G_DAY(2),
      G_LEN TYPE I,
      G_MOD TYPE I.
************************************************************************
* DEFINE: 定义宏
************************************************************************
*普通报表格式的输出宏
DEFINE GRID.
  WRITE: AT /A1   SY-VLINE.
  WRITE: AT  B1   &1.
  WRITE: AT  A2   SY-VLINE.
  WRITE: AT  B2   &2.
  WRITE: AT  A3   SY-VLINE.
  WRITE: AT  B3   &3 RIGHT-JUSTIFIED.
  WRITE: AT  A4   SY-VLINE.
  WRITE: AT  B4   &4 RIGHT-JUSTIFIED.
  WRITE: AT  A5   SY-VLINE.
END-OF-DEFINITION.

DEFINE GRID2.
  WRITE: AT /A1   SY-VLINE.
  WRITE: AT  B1   &1.
  WRITE: AT  A3   SY-VLINE.
  WRITE: AT  B3   &2.
  WRITE: AT  A4   SY-VLINE.
  WRITE: AT  B4   &3.
  WRITE: AT  A5   SY-VLINE.
END-OF-DEFINITION.
************************************************************************
*  SELECTION SCREEN : 定义报表筛选条件
************************************************************************
*确定过滤参数
SELECTION-SCREEN BEGIN OF BLOCK BLK_001 WITH FRAME. TITLE BLK_001 .
   SELECTION-SCREEN SKIP.
    PARAMETERS : P_BUKRS LIKE GLT0-BUKRS OBLIGATORY MEMORY ID 002_1."公司代码
    PARAMETERS : P_RYEAR(4) TYPE C OBLIGATORY MEMORY ID 002_2.      "报表年度
    PARAMETERS : P_MONAT(2) TYPE C OBLIGATORY MEMORY ID 002_3.      "报表期间
   SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK BLK_001.


*===============================事    件===============================*
************************************************************************
* INITIALIZATION.启动程序开始执行
************************************************************************
INITIALIZATION.
  P_RYEAR = SY-DATUM(4).       "会计年度
  P_MONAT = SY-DATUM+4(2) - 1. "会计期间

  PERFORM. SUB_INI.
************************************************************************
* AT SELECTION SCREEN:
************************************************************************
AT SELECTION-SCREEN.
  PERFORM. F_CHECK_INPUT.          "检查用户输入
************************************************************************
* START OF SELECTION:
************************************************************************
START-OF-SELECTION.
*往数据库增加运行日志
  IT_ZREPORTLOG-MANDT = SY-MANDT.
  IT_ZREPORTLOG-TCODE = SY-TCODE.
  IT_ZREPORTLOG-DATUM = SY-DATUM.
  IT_ZREPORTLOG-UZEIT = SY-UZEIT.
  IT_ZREPORTLOG-UNAME = SY-UNAME.
  IT_ZREPORTLOG-TITLE = SY-TITLE.
  APPEND IT_ZREPORTLOG.
  INSERT INTO ZREPORTLOG VALUES IT_ZREPORTLOG .

  PERFORM. CAL_DAY.    "每月天数判断
  PERFORM. F_READ_DATA.
  PERFORM. F_PRINT_REPORT.
************************************************************************
* END OF SELECTION
************************************************************************
END-OF-SELECTION.

************************************************************************
* TOP OF PAGE
************************************************************************
TOP-OF-PAGE.
  PERFORM. SUB_HEAD.
************************************************************************
* END OF PAGE
************************************************************************
END-OF-PAGE.
  PERFORM. SUB_BOTTOM.


*===============================子 例 程===============================*
*&---------------------------------------------------------------------*
*过滤条件有效性检查
*&---------------------------------------------------------------------*
FORM. F_CHECK_INPUT.
DATA: L_DATE LIKE LIKP-ERDAT.

  IF P_MONAT+1(1) = ''.
    CONCATENATE '0' P_MONAT INTO P_MONAT.
  ENDIF.

  CONCATENATE P_RYEAR P_MONAT '01' INTO L_DATE.
  IF L_DATE <= '20050101'.
    MESSAGE E001.    "不能运行该期间的报表!
  ENDIF.

  IF ( P_MONAT < '01' ) OR ( P_MONAT > '16' ).
    MESSAGE E000.    "该会计期间不存在!
  ENDIF.
ENDFORM.                    " F_CHECK_INPUT
*&---------------------------------------------------------------------*
*从数据库中读取数据,填充报表输出时所用的内表
*&---------------------------------------------------------------------*
FORM. F_READ_DATA .
DATA: TAMOUNT1 LIKE GLT0-HSLVT,    "本期数
      TAMOUNT2 LIKE GLT0-HSLVT.    "本年累计数

  SELECT *
    FROM GLT0
    INTO CORRESPONDING FIELDS OF TABLE ITABS
    WHERE BUKRS = P_BUKRS AND RYEAR = P_RYEAR.  "公司代码、会计年度

*开始循环
  LOOP AT ITABS.
   CASE P_MONAT.
     WHEN '01'.
       TAMOUNT1 = ITABS-HSL01.
       TAMOUNT2 = ITABS-HSL01.
     WHEN '02'.
       TAMOUNT1 = ITABS-HSL02.
       TAMOUNT2 = ITABS-HSL01 + ITABS-HSL02.
     WHEN '03'.
       TAMOUNT1 = ITABS-HSL03.
       TAMOUNT2 = ITABS-HSL01 + ITABS-HSL02 + ITABS-HSL03.
     WHEN '04'.
       TAMOUNT1 = ITABS-HSL04.
       TAMOUNT2 = ITABS-HSL01 + ITABS-HSL02 + ITABS-HSL03
                + ITABS-HSL04.
     WHEN '05'.
       TAMOUNT1 = ITABS-HSL05.
       TAMOUNT2 = ITABS-HSL01 + ITABS-HSL02 + ITABS-HSL03
                + ITABS-HSL04 + ITABS-HSL05.
     WHEN '06'.
       TAMOUNT1 = ITABS-HSL06.
       TAMOUNT2 = ITABS-HSL01 + ITABS-HSL02 + ITABS-HSL03
                + ITABS-HSL04 + ITABS-HSL05 + ITABS-HSL06.
     WHEN '07'.
       TAMOUNT1 = ITABS-HSL07.
       TAMOUNT2 = ITABS-HSL01 + ITABS-HSL02 + ITABS-HSL03
                + ITABS-HSL04 + ITABS-HSL05 + ITABS-HSL06 + ITABS-HSL07.
     WHEN '08'.
       TAMOUNT1 = ITABS-HSL08.
       TAMOUNT2 = ITABS-HSL01 + ITABS-HSL02 + ITABS-HSL03
                + ITABS-HSL04 + ITABS-HSL05 + ITABS-HSL06 + ITABS-HSL07
                + ITABS-HSL08.
     WHEN '09'.
       TAMOUNT1 = ITABS-HSL09.
       TAMOUNT2 = ITABS-HSL01 + ITABS-HSL02 + ITABS-HSL03
                + ITABS-HSL04 + ITABS-HSL05 + ITABS-HSL06 + ITABS-HSL07
                + ITABS-HSL08 + ITABS-HSL09.
     WHEN '10'.
       TAMOUNT1 = ITABS-HSL10.
       TAMOUNT2 = ITABS-HSL01 + ITABS-HSL02 + ITABS-HSL03
                + ITABS-HSL04 + ITABS-HSL05 + ITABS-HSL06 + ITABS-HSL07
                + ITABS-HSL08 + ITABS-HSL09 + ITABS-HSL10.
     WHEN '11'.
       TAMOUNT1 = ITABS-HSL11.
       TAMOUNT2 = ITABS-HSL01 + ITABS-HSL02 + ITABS-HSL03
                + ITABS-HSL04 + ITABS-HSL05 + ITABS-HSL06 + ITABS-HSL07
                + ITABS-HSL08 + ITABS-HSL09 + ITABS-HSL10 + ITABS-HSL11.
     WHEN '12' OR '13' OR '14' OR '15' OR '16'.
       TAMOUNT1 = ITABS-HSL12 + ITABS-HSL13 + ITABS-HSL14 + ITABS-HSL15 + ITABS-HSL16.
       TAMOUNT2 = ITABS-HSL01 + ITABS-HSL02 + ITABS-HSL03
                + ITABS-HSL04 + ITABS-HSL05 + ITABS-HSL06 + ITABS-HSL07
                + ITABS-HSL08 + ITABS-HSL09 + ITABS-HSL10 + ITABS-HSL11
                + ITABS-HSL12 + ITABS-HSL13 + ITABS-HSL14 + ITABS-HSL15
                + ITABS-HSL16.
*     WHEN '13'.
*       tamount1 = itabs-hsl13.
*       tamount2 = itabs-hsl01 + itabs-hsl02 + itabs-hsl03
*                + itabs-hsl04 + itabs-hsl05 + itabs-hsl06 + itabs-hsl07
*                + itabs-hsl08 + itabs-hsl09 + itabs-hsl10 + itabs-hsl11
*                + itabs-hsl12 + itabs-hsl13.
*     WHEN '14'.
*       tamount1 = itabs-hsl14.
*       tamount2 = itabs-hsl01 + itabs-hsl02 + itabs-hsl03
*                + itabs-hsl04 + itabs-hsl05 + itabs-hsl06 + itabs-hsl07
*                + itabs-hsl08 + itabs-hsl09 + itabs-hsl10 + itabs-hsl11
*                + itabs-hsl12 + itabs-hsl13 + itabs-hsl14.
*     WHEN '15'.
*       tamount1 = itabs-hsl15.
*       tamount2 = itabs-hsl01 + itabs-hsl02 + itabs-hsl03
*                + itabs-hsl04 + itabs-hsl05 + itabs-hsl06 + itabs-hsl07
*                + itabs-hsl08 + itabs-hsl09 + itabs-hsl10 + itabs-hsl11
*                + itabs-hsl12 + itabs-hsl13 + itabs-hsl14 + itabs-hsl15.
*     WHEN '16'.
*       tamount1 = itabs-hsl16.
*       tamount2 = itabs-hsl01 + itabs-hsl02 + itabs-hsl03
*                + itabs-hsl04 + itabs-hsl05 + itabs-hsl06 + itabs-hsl07
*                + itabs-hsl08 + itabs-hsl09 + itabs-hsl10 + itabs-hsl11
*                + itabs-hsl12 + itabs-hsl13 + itabs-hsl14 + itabs-hsl15
*                + itabs-hsl16.
    ENDCASE.

*  汇总明细科目
    CASE ITABS-RACCT.
      "一、主营业务收入
      WHEN '0051010101' OR '0051010102' OR '0051010301' OR '0051010302'
          OR '0051010303' OR '0051019901'.
        ITAB1-XSSL = ITAB1-XSSL + TAMOUNT1.
        ITAB2-XSSL = ITAB2-XSSL + TAMOUNT2.
      "减:主营业务成本
      WHEN '0054010101' OR '0054010102' OR '0054010301' OR '0054010302'
          OR '0054010303'.
        ITAB1-XSCB = ITAB1-XSCB + TAMOUNT1.
        ITAB2-XSCB = ITAB2-XSCB + TAMOUNT2.
      "减:主营业务税金及附加
      WHEN '0054020001' OR '0054020002' OR '0054020003'
        OR '0054020004' OR '0054020005' OR '0054020099'.
        ITAB1-XSSJ = ITAB1-XSSJ + TAMOUNT1.
        ITAB2-XSSJ = ITAB2-XSSJ + TAMOUNT2.

      "二、主营业务利润(略)
      "加:其他业务利润
      WHEN '0051020000' OR '0051020001' OR '0051020002' ."其他业务收入
        ITAB1-QTYWLR = ITAB1-QTYWLR - TAMOUNT1.
        ITAB2-QTYWLR = ITAB2-QTYWLR - TAMOUNT2.
      WHEN '0054050000' OR '0054050001' OR '0054050002'."其他业务支出
        ITAB1-QTYWLR = ITAB1-QTYWLR - TAMOUNT1.
        ITAB2-QTYWLR = ITAB2-QTYWLR - TAMOUNT2.
      "减:营业费用
      WHEN '0055010000' OR '54010101'.
        ITAB1-XSFY = ITAB1-XSFY + TAMOUNT1.
        ITAB2-XSFY = ITAB2-XSFY + TAMOUNT2.
      "减:管理费用
      WHEN '0055020000' OR '0055020001 ' OR '0055020002'.
        ITAB1-GLFY = ITAB1-GLFY + TAMOUNT1.
        ITAB2-GLFY = ITAB2-GLFY + TAMOUNT2.
      "减:财务费用
      WHEN '0055030001' OR '0055030002' OR '0055030003' OR '0055030004'
       OR '0055030005'.
        ITAB1-CWFY = ITAB1-CWFY + TAMOUNT1.
        ITAB2-CWFY = ITAB2-CWFY + TAMOUNT2.

      "三、营业利润(略)
      "加:投资收益
      WHEN '0052010101' OR '0052010201' OR '0052010301'.
        ITAB1-TZSY = ITAB1-TZSY + TAMOUNT1.
        ITAB2-TZSY = ITAB2-TZSY + TAMOUNT2.
      "补贴收入
      WHEN '0052030001'.
        ITAB1-PTSL = ITAB1-PTSL + TAMOUNT1.
        ITAB2-PTSL = ITAB2-PTSL + TAMOUNT2.
      "营业外收入
      WHEN '0053010001' OR '0053010002' OR '0053010003' OR
           '0053010004' OR '0053010005' OR '0053010099'.
        ITAB1-YYWSL = ITAB1-YYWSL + TAMOUNT1.
        ITAB2-YYWSL = ITAB2-YYWSL + TAMOUNT2.
      "减:营业外支出
      WHEN '0056010001' OR '0056010002' OR '0056010003' OR '0056010004' OR
           '0056010005' OR '0056010006' OR '0056010007' OR '0056010008' OR
           '0056010009' OR '0056010099' .  "增加科目56010009的金额 MODIFY BY ZWM AT 2007-07-02
        ITAB1-YYWZC = ITAB1-YYWZC + TAMOUNT1.
        ITAB2-YYWZC = ITAB2-YYWZC + TAMOUNT2.
      "加:以前年度损益调整
      WHEN '0058010000' OR '0058010001'.
        ITAB1-SYDZ = ITAB1-SYDZ + TAMOUNT1.
        ITAB2-SYDZ = ITAB2-SYDZ + TAMOUNT2.

      "四、利润总额(略)
      "减:所得税
      WHEN '0057010000'.
        ITAB1-SDS = ITAB1-SDS + TAMOUNT1.
        ITAB2-SDS = ITAB2-SDS + TAMOUNT2.
      "五、净利润(略)
    ENDCASE.

*更新内表ITAB1,ITAB2
    MODIFY ITAB1 INDEX SY-TABIX.
    MODIFY ITAB2 INDEX SY-TABIX.
    TAMOUNT1 = 0.
    TAMOUNT2 = 0.
  ENDLOOP.

  IF P_RYEAR = '2005'.      "2005年数据特殊处理
    PERFORM. F_FIRST_DO.
  ENDIF.

  PERFORM. F_CHANGE.         "去负号
  PERFORM. SUB_TOTAL.        "最终数据合计及总计
ENDFORM.                    " F_READ_DATA
*&---------------------------------------------------------------------*
*&      2005年数据特殊处理
*&      从表ZFI03中取2005年2月的累计数据
*&---------------------------------------------------------------------*
FORM. F_FIRST_DO.
  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE ITAB3
    FROM ZFI03
    WHERE RRCTY = '1'
      AND BUKRS = P_BUKRS.
  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE ITAB4
    FROM ZFI03
    WHERE RRCTY = '2'
      AND BUKRS = P_BUKRS.

  LOOP AT ITAB3.
    IF P_MONAT = '02'.
      ITAB2-XSSL = 0 - ITAB3-XSSL.
      ITAB2-XSCB = ITAB3-XSCB.
      ITAB2-XSSJ = ITAB3-XSSJ.
      ITAB2-QTYWLR = ITAB3-QTYWLR.
      ITAB2-XSFY = ITAB3-XSFY.
      ITAB2-GLFY = ITAB3-GLFY.
      ITAB2-CWFY = ITAB3-CWFY.
      ITAB2-TZSY = ITAB3-TZSY.
      ITAB2-YYWSL = 0 - ITAB3-YYWSL.
      ITAB2-YYWZC = ITAB3-YYWZC.
      ITAB2-SYDZ = ITAB3-SYDZ.
      ITAB2-SDS = ITAB3-SDS.

      LOOP AT ITAB4.
        "一、主营业务收入
        ITAB1-XSSL = 0 - ITAB4-XSSL.
        "减:主营业务成本
        ITAB1-XSCB = ITAB4-XSCB.
        "减:主营业务税金及附加
        ITAB1-XSSJ = ITAB4-XSSJ.
        "加:其他业务利润
        ITAB1-QTYWLR = ITAB4-QTYWLR.
        "减:营业费用
        ITAB1-XSFY = ITAB4-XSFY.
        "减:管理费用
        ITAB1-GLFY = ITAB4-GLFY.
        "减:财务费用
        ITAB1-CWFY = ITAB4-CWFY.
        "加:投资收益
        ITAB1-TZSY = ITAB4-TZSY.
        "补贴收入
        ITAB1-PTSL = ITAB4-PTSL.
        "营业外收入
        ITAB1-YYWSL = 0 - ITAB4-YYWSL.
        "减:营业外支出
        ITAB1-YYWZC = ITAB4-YYWZC.
        "加:以前年度损益调整
        ITAB1-SYDZ = ITAB4-SYDZ.
        "减:所得税
        ITAB1-SDS = ITAB4-SDS.
      ENDLOOP.
    ELSE.
      ITAB2-XSSL = ITAB2-XSSL - ITAB3-XSSL.
      ITAB2-XSCB = ITAB2-XSCB + ITAB3-XSCB.
      ITAB2-XSSJ = ITAB2-XSSJ + ITAB3-XSSJ.
      ITAB2-QTYWLR = ITAB2-QTYWLR + ITAB3-QTYWLR.
      ITAB2-XSFY = ITAB2-XSFY + ITAB3-XSFY.
      ITAB2-GLFY = ITAB2-GLFY + ITAB3-GLFY.
      ITAB2-CWFY = ITAB2-CWFY + ITAB3-CWFY.
      ITAB2-TZSY = ITAB2-TZSY + ITAB3-TZSY.
      ITAB2-PTSL = ITAB2-PTSL + ITAB3-PTSL.
      ITAB2-YYWSL = ITAB2-YYWSL - ITAB3-YYWSL.
      ITAB2-YYWZC = ITAB2-YYWZC + ITAB3-YYWZC.
      ITAB2-SYDZ = ITAB2-SYDZ + ITAB3-SYDZ.
      ITAB2-SDS = ITAB2-SDS + ITAB3-SDS.
    ENDIF.

*---更新内表ITAB1,ITAB2
    MODIFY ITAB1 INDEX SY-TABIX.
    MODIFY ITAB2 INDEX SY-TABIX.
  ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*&      去负号
*&---------------------------------------------------------------------*
FORM. F_CHANGE.
**本月数
   ITAB1-XSSL = 0 - ITAB1-XSSL.
   ITAB1-TZSY = 0 - ITAB1-TZSY.
   ITAB1-PTSL = 0 - ITAB1-PTSL.
   ITAB1-YYWSL = 0 - ITAB1-YYWSL.
   ITAB1-SYDZ = 0 - ITAB1-SYDZ.

*本年累计数
   ITAB2-XSSL = 0 - ITAB2-XSSL.
   ITAB2-TZSY = 0 - ITAB2-TZSY.
   ITAB2-PTSL = 0 - ITAB2-PTSL.
   ITAB2-YYWSL = 0 - ITAB2-YYWSL.
   ITAB2-SYDZ = 0 - ITAB2-SYDZ.
ENDFORM.
*&---------------------------------------------------------------------*
*&      最终数据合计及总计
*&---------------------------------------------------------------------*
FORM. SUB_TOTAL.
*处理ITAB1
  "二、主营业务利润
  ITAB1-TOTAL_CSLR = ITAB1-XSSL - ITAB1-XSCB  - ITAB1-XSSJ.
  "三、营业利润
  ITAB1-TOTAL_YYLR = ITAB1-TOTAL_CSLR + ITAB1-QTYWLR - ITAB1-XSFY -
                     ITAB1-GLFY - ITAB1-CWFY.
  "四、利润总额
  ITAB1-TOTAL_LRZE = ITAB1-TOTAL_YYLR + ITAB1-TZSY + ITAB1-PTSL +
                     ITAB1-YYWSL - ITAB1-YYWZC + ITAB1-SYDZ.
  "五、净利润
  ITAB1-TOTAL_JLR = ITAB1-TOTAL_LRZE - ITAB1-SDS.
  MODIFY ITAB1 INDEX SY-TABIX.

*处理ITAB2
  "二、主营业务利润
  ITAB2-TOTAL_CSLR = ITAB2-XSSL - ITAB2-XSCB  - ITAB2-XSSJ.
  "三、营业利润
  ITAB2-TOTAL_YYLR = ITAB2-TOTAL_CSLR + ITAB2-QTYWLR - ITAB2-XSFY -
                     ITAB2-GLFY - ITAB2-CWFY.
  "四、利润总额
  ITAB2-TOTAL_LRZE = ITAB2-TOTAL_YYLR + ITAB2-TZSY + ITAB2-PTSL +
                     ITAB2-YYWSL - ITAB2-YYWZC + ITAB2-SYDZ.
  "五、净利润
  ITAB2-TOTAL_JLR = ITAB2-TOTAL_LRZE - ITAB2-SDS.
  MODIFY ITAB2 INDEX SY-TABIX.
ENDFORM.
*&---------------------------------------------------------------------*
*普通报表格式的打印
*&---------------------------------------------------------------------*
FORM. F_PRINT_REPORT.
  PERFORM. F_CONVERSION.

  GRID '一、主营业务收入' '         1' ITAB1_C-XSSL ITAB2_C-XSSL.
  ULINE AT /21.
  GRID '  减:主营业务成本' '         2' ITAB1_C-XSCB ITAB2_C-XSCB.
  ULINE AT /21.
  GRID '      主营业务税金及附加' '         3' ITAB1_C-XSSJ ITAB2_C-XSSJ.
  ULINE AT /21.
  GRID '二、主营业务利润' '      4=1-2-3' ITAB1_C-TOTAL_CSLR ITAB2_C-TOTAL_CSLR.
  ULINE AT /21.
  GRID '    加:其他业务利润' '         5' ITAB1_C-QTYWLR ITAB2_C-QTYWLR.
  ULINE AT /21.
  GRID '    减:销售费用' '         6' ITAB1_C-XSFY ITAB2_C-XSFY.
  ULINE AT /21.
  GRID '       管理费用' '         7' ITAB1_C-GLFY ITAB2_C-GLFY.
  ULINE AT /21.
  GRID '       财务费用' '         8' ITAB1_C-CWFY ITAB2_C-CWFY.
  ULINE AT /21.
  GRID '三、营业利润' '   9=4+5-6-7-8' ITAB1_C-TOTAL_YYLR ITAB2_C-TOTAL_YYLR.
  ULINE AT /21.
  GRID '    加:投资收益' '         10' ITAB1_C-TZSY ITAB2_C-TZSY.
  ULINE AT /21.
  GRID '       补贴收入' '         11' ITAB1_C-PTSL ITAB2_C-PTSL.
  ULINE AT /21.
  GRID '       营业外收入' '         12' ITAB1_C-YYWSL ITAB2_C-YYWSL.
  ULINE AT /21.
*  GRID '    减:营业处支出' '         13' ITAB1_C-YYWZC ITAB2_C-YYWZC.
  GRID '    减:营业外支出' '         13' ITAB1_C-YYWZC ITAB2_C-YYWZC.
  ULINE AT /21.
  GRID '    加:以前年度损益调整' '         14' ITAB1_C-SYDZ ITAB2_C-SYDZ.
  ULINE AT /21.
  GRID '四、利润总额' '15=9+10+11+12-13+14' ITAB1_C-TOTAL_LRZE ITAB2_C-TOTAL_LRZE.
  ULINE AT /21.
  GRID '    减:所得税' '         16' ITAB1_C-SDS ITAB2_C-SDS.
  ULINE AT /21.
  GRID '五、净利润' '     17=15-16' ITAB1_C-TOTAL_JLR ITAB2_C-TOTAL_JLR.
  ULINE AT /21.

  PERFORM. SUB_BOTTOM.
ENDFORM.                     " F_PRINT_REPORT
*&---------------------------------------------------------------------*
*&      负号转换至数值前头
*&---------------------------------------------------------------------*
FORM. F_CONVERSION.
**传值
   ITAB1_C-XSSL = ITAB1-XSSL.             "一、主营业务收入
   ITAB1_C-XSCB = ITAB1-XSCB.             "减:主营业务成本
   ITAB1_C-XSSJ = ITAB1-XSSJ.             "减:主营业务税金及附加
   ITAB1_C-TOTAL_CSLR = ITAB1-TOTAL_CSLR. "二、主营业务利润
   ITAB1_C-QTYWLR = ITAB1-QTYWLR.         "加:其他业务利润
   ITAB1_C-XSFY = ITAB1-XSFY.             "减:营业费用
   ITAB1_C-GLFY = ITAB1-GLFY.             "减:管理费用
   ITAB1_C-CWFY = ITAB1-CWFY.             "减:财务费用
   ITAB1_C-TOTAL_YYLR = ITAB1-TOTAL_YYLR. "三、营业利润
   ITAB1_C-TZSY = ITAB1-TZSY.             "加:投资收益
   ITAB1_C-PTSL = ITAB1-PTSL.             "加:补贴收入
   ITAB1_C-YYWSL = ITAB1-YYWSL.           "加:营业处收入
   ITAB1_C-YYWZC = ITAB1-YYWZC.           "减:营业外支出
   ITAB1_C-SYDZ = ITAB1-SYDZ.             "加:以前年度损益调整
   ITAB1_C-TOTAL_LRZE = ITAB1-TOTAL_LRZE. "四、利润总额
   ITAB1_C-SDS = ITAB1-SDS.               "减:所得税
   ITAB1_C-TOTAL_JLR = ITAB1-TOTAL_JLR.   "五、净利润

   ITAB2_C-XSSL = ITAB2-XSSL.             "一、主营业务收入
   ITAB2_C-XSCB = ITAB2-XSCB.             "减:主营业务成本
   ITAB2_C-XSSJ = ITAB2-XSSJ.             "减:主营业务税金及附加
   ITAB2_C-TOTAL_CSLR = ITAB2-TOTAL_CSLR. "二、主营业务利润
   ITAB2_C-QTYWLR = ITAB2-QTYWLR.         "加:其他业务利润
   ITAB2_C-XSFY = ITAB2-XSFY.             "减:营业费用
   ITAB2_C-GLFY = ITAB2-GLFY.             "减:管理费用
   ITAB2_C-CWFY = ITAB2-CWFY.             "减:财务费用
   ITAB2_C-TOTAL_YYLR = ITAB2-TOTAL_YYLR. "三、营业利润
   ITAB2_C-TZSY = ITAB2-TZSY.             "加:投资收益
   ITAB2_C-PTSL = ITAB2-PTSL.             "加:补贴收入
   ITAB2_C-YYWSL = ITAB2-YYWSL.           "加:营业处收入
   ITAB2_C-YYWZC = ITAB2-YYWZC.           "减:营业外支出
   ITAB2_C-SYDZ = ITAB2-SYDZ.             "加:以前年度损益调整
   ITAB2_C-TOTAL_LRZE = ITAB2-TOTAL_LRZE. "四、利润总额
   ITAB2_C-SDS = ITAB2-SDS.               "减:所得税
   ITAB2_C-TOTAL_JLR = ITAB2-TOTAL_JLR.   "五、净利润

**本月数
   IF ITAB1-XSSL < 0.
     ITAB1_C-XSSL = 0 - ITAB1-XSSL.
     CONCATENATE '-' ITAB1_C-XSSL INTO ITAB1_C-XSSL.
     CONDENSE ITAB1_C-XSSL.
   ENDIF.

   IF ITAB1-XSCB < 0.
     ITAB1_C-XSCB = 0 - ITAB1-XSCB.
     CONCATENATE '-' ITAB1_C-XSCB INTO ITAB1_C-XSCB.
     CONDENSE ITAB1_C-XSCB.
   ENDIF.
   IF ITAB1-XSSJ < 0.
     ITAB1_C-XSSJ = 0 - ITAB1-XSSJ.
     CONCATENATE '-' ITAB1_C-XSSJ INTO ITAB1_C-XSSJ.
     CONDENSE ITAB1_C-XSSJ.
   ENDIF.

   IF ITAB1-TOTAL_CSLR < 0.
     ITAB1_C-TOTAL_CSLR = 0 - ITAB1-TOTAL_CSLR.
     CONCATENATE '-' ITAB1_C-TOTAL_CSLR INTO ITAB1_C-TOTAL_CSLR.
     CONDENSE ITAB1_C-TOTAL_CSLR.
   ENDIF.
   IF ITAB1-QTYWLR < 0.
     ITAB1_C-QTYWLR = 0 - ITAB1-QTYWLR.
     CONCATENATE '-' ITAB1_C-QTYWLR INTO ITAB1_C-QTYWLR.
     CONDENSE ITAB1_C-QTYWLR.
   ENDIF.

   IF ITAB1-XSFY < 0.
     ITAB1_C-XSFY = 0 - ITAB1-XSFY.
     CONCATENATE '-' ITAB1_C-XSFY INTO ITAB1_C-XSFY.
     CONDENSE ITAB1_C-XSFY.
   ENDIF.
   IF ITAB1-GLFY < 0.
     ITAB1_C-GLFY = 0 - ITAB1-GLFY.
     CONCATENATE '-' ITAB1_C-GLFY INTO ITAB1_C-GLFY.
     CONDENSE ITAB1_C-GLFY.
   ENDIF.
   IF ITAB1-CWFY < 0.
     ITAB1_C-CWFY = 0 - ITAB1-CWFY.
     CONCATENATE '-' ITAB1_C-CWFY INTO ITAB1_C-CWFY.
     CONDENSE ITAB1_C-CWFY.
   ENDIF.

   IF ITAB1-TOTAL_YYLR < 0.
     ITAB1_C-TOTAL_YYLR = 0 - ITAB1-TOTAL_YYLR.
     CONCATENATE '-' ITAB1_C-TOTAL_YYLR INTO ITAB1_C-TOTAL_YYLR.
     CONDENSE ITAB1_C-TOTAL_YYLR.
   ENDIF.
   IF ITAB1-TZSY < 0.
     ITAB1_C-TZSY = 0 - ITAB1-TZSY.
     CONCATENATE '-' ITAB1_C-TZSY INTO ITAB1_C-TZSY.
     CONDENSE ITAB1_C-TZSY.
   ENDIF.
   IF ITAB1-PTSL < 0.
     ITAB1_C-PTSL = 0 - ITAB1-PTSL.
     CONCATENATE '-' ITAB1_C-PTSL INTO ITAB1_C-PTSL.
     CONDENSE ITAB1_C-PTSL.
   ENDIF.
   IF ITAB1-YYWSL < 0.
     ITAB1_C-YYWSL = 0 - ITAB1-YYWSL.
     CONCATENATE '-' ITAB1_C-YYWSL INTO ITAB1_C-YYWSL.
     CONDENSE ITAB1_C-YYWSL.
   ENDIF.
   IF ITAB1-YYWZC < 0.
     ITAB1_C-YYWZC = 0 - ITAB1-YYWZC.
     CONCATENATE '-' ITAB1_C-YYWZC INTO ITAB1_C-YYWZC.
     CONDENSE ITAB1_C-YYWZC.
   ENDIF.
   IF ITAB1-SYDZ < 0.
     ITAB1_C-SYDZ = 0 - ITAB1-SYDZ.
     CONCATENATE '-' ITAB1_C-SYDZ INTO ITAB1_C-SYDZ.
     CONDENSE ITAB1_C-SYDZ.
   ENDIF.

   IF ITAB1-TOTAL_LRZE < 0.
     ITAB1_C-TOTAL_LRZE = 0 - ITAB1-TOTAL_LRZE.
     CONCATENATE '-' ITAB1_C-TOTAL_LRZE INTO ITAB1_C-TOTAL_LRZE.
     CONDENSE ITAB1_C-TOTAL_LRZE.
   ENDIF.
   IF ITAB1-SDS < 0.
     ITAB1_C-SDS = 0 - ITAB1-SDS.
     CONCATENATE '-' ITAB1_C-SDS INTO ITAB1_C-SDS.
     CONDENSE ITAB1_C-SDS.
   ENDIF.

   IF ITAB1-TOTAL_JLR < 0.
     ITAB1_C-TOTAL_JLR = 0 - ITAB1-TOTAL_JLR.
     CONCATENATE '-' ITAB1_C-TOTAL_JLR INTO ITAB1_C-TOTAL_JLR.
     CONDENSE ITAB1_C-TOTAL_JLR.
   ENDIF.

*本年累计数
   IF ITAB2-XSSL < 0.
     ITAB2_C-XSSL = 0 - ITAB2-XSSL.
     CONCATENATE '-' ITAB2_C-XSSL INTO ITAB2_C-XSSL.
     CONDENSE ITAB2_C-XSSL.
   ENDIF.
   IF ITAB2-XSCB < 0.
     ITAB2_C-XSCB = 0 - ITAB2-XSCB.
     CONCATENATE '-' ITAB2_C-XSCB INTO ITAB2_C-XSCB.
     CONDENSE ITAB2_C-XSCB.
   ENDIF.
   IF ITAB2-XSSJ < 0.
     ITAB2_C-XSSJ = 0 - ITAB2-XSSJ.
     CONCATENATE '-' ITAB2_C-XSSJ INTO ITAB2_C-XSSJ.
     CONDENSE ITAB2_C-XSSJ.
   ENDIF.

   IF ITAB2-TOTAL_CSLR < 0.
     ITAB2_C-TOTAL_CSLR = 0 - ITAB2-TOTAL_CSLR.
     CONCATENATE '-' ITAB2_C-TOTAL_CSLR INTO ITAB2_C-TOTAL_CSLR.
     CONDENSE ITAB2_C-TOTAL_CSLR.
   ENDIF.
   IF ITAB2-QTYWLR < 0.
     ITAB2_C-QTYWLR = 0 - ITAB2-QTYWLR.
     CONCATENATE '-' ITAB2_C-QTYWLR INTO ITAB2_C-QTYWLR.
     CONDENSE ITAB2_C-QTYWLR.
   ENDIF.

   IF ITAB2-XSFY < 0.
     ITAB2_C-XSFY = 0 - ITAB2-XSFY.
     CONCATENATE '-' ITAB2_C-XSFY INTO ITAB2_C-XSFY.
     CONDENSE ITAB2_C-XSFY.
   ENDIF.
   IF ITAB2-GLFY < 0.
     ITAB2_C-GLFY = 0 - ITAB2-GLFY.
     CONCATENATE '-' ITAB2_C-GLFY INTO ITAB2_C-GLFY.
     CONDENSE ITAB2_C-GLFY.
   ENDIF.
   IF ITAB2-CWFY < 0.
     ITAB2_C-CWFY = 0 - ITAB2-CWFY.
     CONCATENATE '-' ITAB2_C-CWFY INTO ITAB2_C-CWFY.
     CONDENSE ITAB2_C-CWFY.
   ENDIF.

   IF ITAB2-TOTAL_YYLR < 0.
     ITAB2_C-TOTAL_YYLR = 0 - ITAB2-TOTAL_YYLR.
     CONCATENATE '-' ITAB2_C-TOTAL_YYLR INTO ITAB2_C-TOTAL_YYLR.
     CONDENSE ITAB2_C-TOTAL_YYLR.
   ENDIF.
   IF ITAB2-TZSY < 0.
     ITAB2_C-TZSY = 0 - ITAB2-TZSY.
     CONCATENATE '-' ITAB2_C-TZSY INTO ITAB2_C-TZSY.
     CONDENSE ITAB2_C-TZSY.
   ENDIF.
   IF ITAB2-PTSL < 0.
     ITAB2_C-PTSL = 0 - ITAB2-PTSL.
     CONCATENATE '-' ITAB2_C-PTSL INTO ITAB2_C-PTSL.
     CONDENSE ITAB2_C-PTSL.
   ENDIF.
   IF ITAB2-YYWSL < 0.
     ITAB2_C-YYWSL = 0 - ITAB2-YYWSL.
     CONCATENATE '-' ITAB2_C-YYWSL INTO ITAB2_C-YYWSL.
     CONDENSE ITAB2_C-YYWSL.
   ENDIF.
   IF ITAB2-YYWZC < 0.
     ITAB2_C-YYWZC = 0 - ITAB2-YYWZC.
     CONCATENATE '-' ITAB2_C-YYWZC INTO ITAB2_C-YYWZC.
     CONDENSE ITAB2_C-YYWZC.
   ENDIF.
   IF ITAB2-SYDZ < 0.
     ITAB2_C-SYDZ = 0 - ITAB2-SYDZ.
     CONCATENATE '-' ITAB2_C-SYDZ INTO ITAB2_C-SYDZ.
     CONDENSE ITAB2_C-SYDZ.
   ENDIF.

   IF ITAB2-TOTAL_LRZE < 0.
     ITAB2_C-TOTAL_LRZE = 0 - ITAB2-TOTAL_LRZE.
     CONCATENATE '-' ITAB2_C-TOTAL_LRZE INTO ITAB2_C-TOTAL_LRZE.
     CONDENSE ITAB2_C-TOTAL_LRZE.
   ENDIF.
   IF ITAB2-SDS < 0.
     ITAB2_C-SDS = 0 - ITAB2-SDS.
     CONCATENATE '-' ITAB2_C-SDS INTO ITAB2_C-SDS.
     CONDENSE ITAB2_C-SDS.
   ENDIF.

   IF ITAB2-TOTAL_JLR < 0.
     ITAB2_C-TOTAL_JLR = 0 - ITAB2-TOTAL_JLR.
     CONCATENATE '-' ITAB2_C-TOTAL_JLR INTO ITAB2_C-TOTAL_JLR.
     CONDENSE ITAB2_C-TOTAL_JLR.
   ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*&      单据表头显示
*&---------------------------------------------------------------------*
FORM. SUB_HEAD.
DATA:L_COMP(22),
     L_TAXNO(15).

  SELECT BUTXT TXJCD
    FROM ZFI15
    INTO (L_COMP,L_TAXNO)
    WHERE BUKRS = P_BUKRS.
  ENDSELECT.

*  "取纳税人名称、识别号
*  IF P_BUKRS = '1000'.
*    L_COMP = '厦门市松霖卫浴有限公司'.
*    L_TAXNO = '350206612034279'.
*  ELSEIF P_BUKRS = '2000'.
*    L_COMP = '厦门市益周塑胶制造有限公司'.
*    L_TAXNO = '350206751630580'.
*  ELSEIF P_BUKRS = '3000'.
*    L_COMP = '厦门市易洁卫浴有限公司'.
*    L_TAXNO = '350206751625845'.
*  ELSEIF P_BUKRS = '4000'.
*    L_COMP = '厦门市玩铜五金制造有限公司'.
*    L_TAXNO = '350206776010206'.
*  ELSEIF P_BUKRS = '5000'.
*    L_COMP = '厦门市松霖科技有限公司'.
*    L_TAXNO = '350205751643429'.
*  ELSEIF P_BUKRS = '6000'.
*    L_COMP = '厦门市安坤热水器有限公司'.
*    L_TAXNO = ''.
*  ELSEIF P_BUKRS = '7000'.
*    L_COMP = '厦门市欧准卫浴用品有限公司'.
*    L_TAXNO = ''.
*  ENDIF.

  "取税款所属期
  IF P_MONAT > '12'.
    P_MONAT = '12'.
  ENDIF.

  WRITE: /75  '损  益  表'.
  SKIP.
  WRITE: /22 '纳税人识别号:',L_TAXNO.
  WRITE: 99 '纳税人名称:',L_COMP.
  WRITE: /22 '税款所属期:',P_RYEAR,'-',P_MONAT,'-','01',
            '至',P_RYEAR,'-',P_MONAT,'-',G_DAY.
  WRITE: 99 '填表日期:',SY-DATUM,'    金额单位:人民币元'.
  ULINE  AT /A1 .

  GRID '               项       目' '        行次'
       '           本月数' '           本年累计数'.
  ULINE AT /21.
ENDFORM.                    " SUB_OUTPUTHEAD
*&---------------------------------------------------------------------
*&      单据表尾显示
*&---------------------------------------------------------------------
FORM. SUB_BOTTOM.
 SKIP.
 WRITE: /22 '补充资料:'.
 ULINE AT /21.
 GRID2 '               项       目' '          本年累计数'
       '           上年实际数'.
 ULINE AT /21.
 GRID2 '1.出售、处置部门或被投资单位所得收益' '' ''.
 ULINE AT /21.
 GRID2 '2.自然灾害发生的损失' '' ''.
 ULINE AT /21.
 GRID2 '3.会计政策变更增加(或减少)利润总额' '' ''.
 ULINE AT /21.
 GRID2 '4.会计估计变更增加(或减少)利润总额' '' ''.
 ULINE AT /21.
 GRID2 '5.债务重组损失' '' ''.
 ULINE AT /21.
 GRID2 '6.其他' '' ''.
 ULINE AT /21.
 SKIP.
 WRITE: AT 22 '单位负责人:','                财会负责人:'.
 WRITE: AT 80 '复核:','                  制表:'.
ENDFORM.                    "SUB_BOTTOM
*&---------------------------------------------------------------------*
*       各月天数判断
*----------------------------------------------------------------------*
FORM. CAL_DAY.
 IF P_MONAT = '04' OR P_MONAT = '06' OR
   P_MONAT = '09' OR P_MONAT = '11'.
   G_DAY = '30'.
 ELSEIF P_MONAT = '02'.
   G_MOD = P_RYEAR MOD 4.
   IF G_MOD = 0.
     G_DAY = '29'.
   ELSE.
     G_DAY = '28'.
   ENDIF.
 ELSE.
   G_DAY = '31'.
 ENDIF.
 CONDENSE G_DAY NO-GAPS.
ENDFORM.                    "CAL_DAY
*&---------------------------------------------------------------------*
*&      单据表格上相关坐标值初始
*&---------------------------------------------------------------------*
FORM. SUB_INI .
  MOVE 21  TO  A1.   "项目
  MOVE 22  TO  B1.
  MOVE 60  TO  A2.   "行次
  MOVE 61  TO  B2.
  MOVE 80  TO  A3.   "本月数
  MOVE 81  TO  B3.
  MOVE 113 TO  A4.   "本年累计数
  MOVE 114 TO  B4.
  MOVE 143 TO  A5.
ENDFORM.                    " SUB_INI

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/765243/viewspace-253284/,如需转载,请注明出处,否则将追究法律责任。

上一篇: ZR_FI_001
下一篇: ZR_FI_003
请登录后发表评论 登录
全部评论

注册时间:2006-03-01

  • 博文量
    43
  • 访问量
    33244