ITPub博客

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

ZR_FI_013

原创 Linux操作系统 作者:williamzhou 时间:2019-04-25 20:57:05 0 删除 编辑

*===============================基本信息===============================*
* 标题:损益报表
* 创建日期:2005-01-20        
*===============================定    义===============================*

************************************************************************
* 基本代码
************************************************************************
REPORT ZR_FI_013
NO STANDARD PAGE HEADING
LINE-COUNT 75
LINE-SIZE  135
MESSAGE-ID ZFI1.

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

************************************************************************
* TABLE: 定义TABLE
************************************************************************
TABLES:
  SKAT,         "总帐科目主记录(科目表:说明)
  GLT0,         "总帐科目主记录业务额
  T001,         "公司代码
  VBFA,         "销售凭证流
  VBRK,
  VBRP,
  VBKD,         "销售凭证 : 业务数据
  RF011Z,       "将资产负债表行项目分配到科目
  RF011Q.       "会计报表项说明文字
************************************************************************
*INTERNAL TABLES
************************************************************************
*定义内表ITABS(作为辅助使用)
  DATA: BEGIN OF ITABS OCCURS 10.
        INCLUDE STRUCTURE GLT0.
        DATA: PSWBT LIKE BSIS-PSWBT."营业外支出科目
        DATA: PSWBT1 LIKE BSIS-PSWBT."1营业外支出科目
        DATA: PSWBT2 LIKE BSIS-PSWBT."2营业外支出科目
        DATA: PSWBT3 LIKE BSIS-PSWBT."3营业外支出科目
        DATA: PSWBT4 LIKE BSIS-PSWBT."4营业外支出科目
        DATA: PSWBT5 LIKE BSIS-PSWBT."5营业外支出科目
        DATA: PSWBT6 LIKE BSIS-PSWBT."6营业外支出科目
        DATA: PSWBT7 LIKE BSIS-PSWBT."7营业外支出科目
        DATA: PSWBT8 LIKE BSIS-PSWBT."8营业外支出科目
        DATA: PSWBT9 LIKE BSIS-PSWBT."9营业外支出科目
        DATA: PSWBT10 LIKE BSIS-PSWBT."10营业外支出科目
        DATA: PSWBT11 LIKE BSIS-PSWBT."11营业外支出科目
        DATA: PSWBT12 LIKE BSIS-PSWBT."12营业外支出科目

        DATA: PSWB LIKE BSIS-PSWBT."营业外收入科目
        DATA: PSWB1 LIKE BSIS-PSWBT."1营业外收入科目
        DATA: PSWB2 LIKE BSIS-PSWBT."2营业外收入科目
        DATA: PSWB3 LIKE BSIS-PSWBT."3营业外收入科目
        DATA: PSWB4 LIKE BSIS-PSWBT."4营业外收入科目
        DATA: PSWB5 LIKE BSIS-PSWBT."5营业外收入科目
        DATA: PSWB6 LIKE BSIS-PSWBT."6营业外收入科目
        DATA: PSWB7 LIKE BSIS-PSWBT."7营业外收入科目
        DATA: PSWB8 LIKE BSIS-PSWBT."8营业外收入科目
        DATA: PSWB9 LIKE BSIS-PSWBT."9营业外收入科目
        DATA: PSWB10 LIKE BSIS-PSWBT."10营业外收入科目
        DATA: PSWB11 LIKE BSIS-PSWBT."11营业外收入科目
        DATA: PSWB12 LIKE BSIS-PSWBT."12营业外收入科目
  DATA: END OF ITABS.

*定义本期数内表ITAB1
DATA: BEGIN OF ITAB1 OCCURS 0,
        CPXSSR LIKE GLT0-HSLVT,    "1产品销售收入
        CLCB LIKE GLT0-HSLVT,      "2材料成本
        CLCBCY LIKE GLT0-HSLVT,    "3材料成本差异
        SCCBCY LIKE GLT0-HSLVT,    "4生产成本差异
        JGCGTZ LIKE GLT0-HSLVT,    "41价格重估调整
        CPXSSJ LIKE GLT0-HSLVT,    "5产品销售税金几附加
        YTCKSJ LIKE GLT0-HSLVT,    "6预提当月出口税金
        CPXSML LIKE GLT0-HSLVT,    "7产品销售毛利

        XSFY LIKE GLT0-HSLVT,      "8销售费用
        GLFY LIKE GLT0-HSLVT,      "9管理费用
        CWFY LIKE GLT0-HSLVT,      "10财务费用
        YYFYHJ LIKE GLT0-HSLVT,    "11营业费用合计

        QTYWZC LIKE GLT0-HSLVT,     "12其他业务支出
        YYWZC LIKE GLT0-HSLVT,      "13营业外支出
        QTYWZCHJ LIKE GLT0-HSLVT,   "14其他支出合计

        QTYWSR LIKE GLT0-HSLVT,     "15其他业务收入
        YYWSR LIKE GLT0-HSLVT,      "16营业外收入
        PTSR LIKE GLT0-HSLVT,       "16_1补贴收入
        QTYWSRHJ LIKE GLT0-HSLVT,   "17其他业务收入合计

        SYDZ LIKE GLT0-HSLVT,       "17_1以前年度损益调整

        SQJLR LIKE GLT0-HSLVT,      "18税前净利润
        SDS   LIKE GLT0-HSLVT,      "19所得税
        JLR LIKE GLT0-HSLVT,        "20净利润
        JTSR LIKE GLT0-HSLVT,       "24集团层收入
        JTCB1 LIKE GLT0-HSLVT,       "25集团层成本1
        JTCB LIKE GLT0-HSLVT,       "25集团层成本
        JTSJFJ LIKE GLT0-HSLVT,     "26集团层税金及附金
        JTLXSR LIKE GLT0-HSLVT,     "27集团层利息收入
        JTLXZC LIKE GLT0-HSLVT,     "28集团层利息支出
        JTZLR LIKE GLT0-HSLVT,      "29净利润(集团层)
      END OF ITAB1.

*定义本期占销售百分比数内表ITAB2
DATA: ITAB2 LIKE ITAB1 OCCURS 10 WITH HEADER LINE.
*定义去年本期数内表ITAB3
DATA: ITAB3 LIKE ITAB1 OCCURS 10 WITH HEADER LINE.
*定义去年本期数占销售百分比内表ITAB4
DATA: ITAB4 LIKE ITAB1 OCCURS 10 WITH HEADER LINE.
*定义本本期比去年本期百分比内表ITAB5
DATA: ITAB5 LIKE ITAB1.

*定义本年累计数内表ITAB6
DATA: ITAB6 LIKE ITAB1 OCCURS 10 WITH HEADER LINE.
*定义去年累计数占销售百分比内表ITAB7
DATA: ITAB7 LIKE ITAB1 OCCURS 10 WITH HEADER LINE.
*定义去年累计数内表ITAB8
DATA: ITAB8 LIKE ITAB1 OCCURS 10 WITH HEADER LINE.
*定义去年累计数占销售百分比内表ITAB9
DATA: ITAB9 LIKE ITAB1 OCCURS 10 WITH HEADER LINE.
*定义本去年累计数比去年本期百分比内表ITAB10
DATA: ITAB10 LIKE ITAB1 OCCURS 10 WITH HEADER LINE.

*定义字符型字段的内表-本期数(用于转换数值的负号显示形式)
DATA: BEGIN OF ITAB1_C OCCURS 0,
        CPXSSR(20),    "1产品销售收入
        CLCB(20),      "2材料成本
        CLCBCY(20),    "3材料成本差异
        SCCBCY(20),    "4生产成本差异
        JGCGTZ(20),    "41价格重估调整
        CPXSSJ(20),    "5产品销售税金几附加
        YTCKSJ(20),    "6预提当月出口税金
        CPXSML(20),    "7产品销售毛利

        XSFY(20),      "8销售费用
        GLFY(20),      "9管理费用
        CWFY(20),      "10财务费用
        YYFYHJ(20),    "11营业费用合计

        QTYWZC(20),     "12其他业务支出
        YYWZC(20),      "13营业外支出
        QTYWZCHJ(20),   "14其他支出合计

        QTYWSR(20),     "15其他业务收入
        YYWSR(20),      "16营业外收入
        PTSR(20),       "16_1补贴收入
        QTYWSRHJ(20),   "17其他业务收入合计

        SYDZ(20),       "17_1以前年度损益调整

        SQJLR(20),      "18税前净利润
        SDS(20),        "19所得税
        JLR(20),        "20净利润
        JTSR(20),       "24集团层收入
        JTCB(20),       "25集团层成本
        JTSJFJ(20),     "26集团层税金及附金
        JTLXSR(20),     "27集团层利息收入
        JTLXZC(20),     "28集团层利息支出
        JTZLR(20),      "29净利润(集团层)
      END OF ITAB1_C.

*定义去年本期数内表ITAB3
DATA: ITAB3_C LIKE ITAB1_C OCCURS 10 WITH HEADER LINE.

*定义本年累计数内表ITAB6
DATA: ITAB6_C LIKE ITAB1_C OCCURS 10 WITH HEADER LINE.
*定义去年累计数内表ITAB8
DATA: ITAB8_C LIKE ITAB1_C OCCURS 10 WITH HEADER LINE.

*定义内表,处理非寄售出退货信息
DATA: BEGIN OF IT_PRINT_001 OCCURS 0.
        DATA FLAG TYPE I.
        DATA CNO1 LIKE LIKP-KUNAG.         "客户代码,售达方
        DATA CNO LIKE KNA1-KUNNR.          "客户代码,送达方
        DATA CNAME LIKE KNA1-NAME1.        "客户名称
        DATA CLASS LIKE KNA1-NAME1.        "事务类别
        DATA ORDERNO LIKE LIKP-VBELN.      "交退货单号
        DATA ORDERDATE LIKE LIKP-ERDAT.    "交货单/退货交货单日期
        DATA OLDERDATE LIKE LIKP-ERDAT.    "交货单原始日期
        DATA OTHERNO LIKE LIKP-VBELN.      "交货单参考单号
        DATA PRODNO LIKE LIPS-MATNR.       "产品型号
        DATA PRODNAME LIKE MAKT-MAKTX.     "产品名称
        DATA PRODQTY LIKE LIPS-LFIMG.      "数量
        DATA PRICE LIKE LIPS-NETPR.        "单价
        DATA AMOUNT LIKE LIPS-NETPR.       "金额
        DATA KURSK LIKE VBKD-KURSK.        "汇率
        DATA WAERK LIKE VBAK-WAERK.        "币别

        DATA PRODQTY_C(20).
        DATA AMOUNT_C(20).
        DATA FKSTK LIKE VBUK-FKSTK.         "开票状态
        DATA POSNR LIKE LIPS-POSNR.         "交货项目号
        DATA AUART LIKE VBAK-AUART.         "订单类型
        DATA VGBEL LIKE LIPS-VGBEL.         "参考凭证的凭证号(销售订单号)
        DATA VGPOS LIKE LIPS-VGPOS.         "销售和分销凭证的项目号
        DATA VBELN LIKE VBRK-VBELN.         "开票凭证号
        DATA VBELN2 LIKE VBRK-VBELN.        "发货过账物料凭证号
        DATA VBELN3 LIKE VBRK-VBELN.        "发货过账会计凭证号
        DATA KDMAT LIKE LIPS-KDMAT.         "客户物料号
        DATA BSTNK LIKE VBAK-BSTNK.         "采购订单编号
        DATA VTWEG LIKE VBAK-VTWEG.         "分销渠道
        DATA PRICE_SR LIKE LIPS-NETPR.      "销售单价
        DATA PRICE_CB LIKE LIPS-NETPR.      "成本单价
        DATA AMOUNT_SR LIKE LIPS-NETPR.     "销售金额
        DATA AMOUNT_CB LIKE LIPS-NETPR.     "成本金额
        DATA CLASSNAME LIKE KNA1-NAME1.     "事务类别名称
        DATA KODAT LIKE LIKP-KODAT.         "拣配日期
DATA: END OF IT_PRINT_001.

DATA: IT_TEMP LIKE IT_PRINT_001 OCCURS 10 WITH HEADER LINE.

*定义内表IT_PRINT_003
DATA: BEGIN OF IT_PRINT_003 OCCURS 10.
        INCLUDE STRUCTURE MBEWH.
      DATA: MBEWH_DATE LIKE LIKP-ERDAT.
      DATA: BELNR LIKE MLCRP-BELNR.
DATA: END OF IT_PRINT_003.
*定义内表IT_PRINT_103
DATA: BEGIN OF IT_PRINT_103 OCCURS 10.
        INCLUDE STRUCTURE MLCRP.
      DATA: MBEWH_DATE LIKE LIKP-ERDAT.
DATA: END OF IT_PRINT_103.

*取销售净价及货币
DATA: BEGIN OF IT_PRINT_004 OCCURS 0.
        DATA NETPR LIKE VBAP-NETPR.        "净价
        DATA WAERK LIKE VBAP-WAERK.        "SD 凭证货币
        DATA KPEIN LIKE VBAP-KPEIN.        "条件定价单位
DATA: END OF IT_PRINT_004.
*取汇率
DATA: BEGIN OF IT_PRINT_005 OCCURS 0.
        DATA UKURS LIKE TCURR-UKURS.        "汇率
        DATA GDATU LIKE TCURR-GDATU.        "汇率有效起始日期
DATA: END OF IT_PRINT_005.

*定义内表IT_PRINT_006(处理损益表数据)
DATA: BEGIN OF IT_PRINT_006 OCCURS 10.
        INCLUDE STRUCTURE ZFI01.
DATA: END OF IT_PRINT_006.
*定义内表ITAB_HT(保存数据至后台)
DATA: BEGIN OF ITAB_HT OCCURS 10.
        INCLUDE STRUCTURE ZFI04.
DATA: END OF ITAB_HT.

*定义内表IT_PRINT_007(处理交货凭证流)
DATA: BEGIN OF IT_PRINT_007 OCCURS 10.
        DATA VBELV LIKE VBFA-VBELV.         "先前凭证
        DATA VBELN LIKE VBFA-VBELN.         "后续凭证
        DATA VBTYP_N LIKE VBFA-VBTYP_N.     "后继凭证的凭证类别
DATA: END OF IT_PRINT_007.

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

*定义用ALV导出科目值内表
DATA: BEGIN OF ITAB_KM OCCURS 10.
        DATA CNO LIKE KNA1-KUNNR.       "序号
        DATA NAME LIKE KNA1-NAME1.      "名称
        DATA NC LIKE GLT0-HSLVT.        "年初值
        DATA BQ LIKE GLT0-HSLVT.        "本期值
        DATA BN LIKE GLT0-HSLVT.        "本年值
DATA: END OF ITAB_KM.

*ALV导出内表
DATA: ITAB_ALV LIKE IT_PRINT_001 OCCURS 10 WITH HEADER LINE.

*往数据库增加运行日志
  DATA: BEGIN OF IT_ZREPORTLOG OCCURS  0.
    INCLUDE TYPE ZREPORTLOG.
  DATA: END OF IT_ZREPORTLOG.
************************************************************************
* CONSTANTS : 定义常量
************************************************************************
DATA: L_PRICE_SR TYPE P DECIMALS 6,
      L_PRICE_CB TYPE P DECIMALS 6,
      L_AMOUNT_SR TYPE P DECIMALS 6,
      L_AMOUNT_CB TYPE P DECIMALS 6,
      L_AMOUNT_SR2 TYPE P DECIMALS 6,
      L_AMOUNT_CB2 TYPE P DECIMALS 6,
*      L_AMOUNT_SR LIKE LIPS-NETPR,
*      L_AMOUNT_CB LIKE LIPS-NETPR,
*      L_AMOUNT_SR2 LIKE LIPS-NETPR,
*      L_AMOUNT_CB2 LIKE LIPS-NETPR,
      L_TAX TYPE P DECIMALS 2 VALUE '0.17'.
DATA: L_MSYTZS LIKE BSIS-PSWBT."集团本期损益调整借方科目
DATA: L_MSYTZH LIKE BSIS-PSWBT."集团本期损益调整贷方科目
DATA: L_YSYTZS LIKE BSIS-PSWBT."集团本年损益调整借方科目
DATA: L_YSYTZH LIKE BSIS-PSWBT."集团本年损益调整借方科目
************************************************************************
* 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,
      A6 TYPE I VALUE 0,
      A7 TYPE I VALUE 0,
      A8 TYPE I VALUE 0,
      A9 TYPE I VALUE 0,
      A10 TYPE I VALUE 0,
      A11 TYPE I VALUE 0,
      A12 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,
      B5 TYPE I VALUE 0,
      B6 TYPE I VALUE 0,
      B7 TYPE I VALUE 0,
      B8 TYPE I VALUE 0,
      B9 TYPE I VALUE 0,
      B10 TYPE I VALUE 0,
      B11 TYPE I VALUE 0.

DATA: G_DAY(2),
      G_LEN TYPE I,
      G_MOD TYPE I,
      P_RYEAR_L(4),                 "去年度
      G_PRODNO LIKE LIPS-MATNR,
      G_DATE LIKE LIKP-ERDAT,
      G_PRICE TYPE P DECIMALS 6,
      G_VGBEL LIKE VBAK-VGBEL,
      G_FKSTK LIKE VBUK-FKSTK.      "开票状态

*用于ALV控件双击事件
DATA: G_SELECTED_FIELD_VALUE(80).

*ALV控件构造时需要的参数
DATA: G_ALV_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
      G_ALV_FIELDCAT_LINE LIKE LINE OF G_ALV_FIELDCAT,
      G_ALV_EVENT         TYPE SLIS_T_EVENT.

*ALV控件输出的表头
DATA: G_ALV_LISTHEADER TYPE SLIS_T_LISTHEADER.

*指定ALV控件触发TOP_OF_PAGE事件时调用的子程序
DATA: G_ALV_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME
             VALUE 'F_ALV_EVENT_TOP_OF_PAGE'.
DATA: G_ALV_FORMNAME_END_OF_LIST TYPE SLIS_FORMNAME
             VALUE 'F_ALV_EVENT_END_OF_LIST'.

*指定ALV控件的显示特征
DATA : G_ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
************************************************************************
* 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 LEFT-JUSTIFIED.
  WRITE: AT  A4   SY-VLINE.
  WRITE: AT  B4   &4 LEFT-JUSTIFIED.
  WRITE: AT  A5   SY-VLINE.
END-OF-DEFINITION.

DATA L8(15).
DEFINE GRID1.
  CLEAR L8.
  MOVE &1 TO L8.
  IF &1 < 0.
    CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
       CHANGING
          VALUE   = L8
     EXCEPTIONS
         OTHERS  = 1.
  ENDIF.
  SHIFT L8 LEFT DELETING LEADING SPACE.
  WRITE: AT /A1   SY-VLINE.
  WRITE: AT  B1   L8  LEFT-JUSTIFIED.
  WRITE: AT  A2   SY-VLINE.
  CLEAR L8.
  MOVE &2 TO L8.
  IF &2 < 0.
    CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
       CHANGING
          VALUE   = L8
     EXCEPTIONS
         OTHERS  = 1.
  ENDIF.
  SHIFT L8 LEFT DELETING LEADING SPACE.
  WRITE: AT  B2   L8  LEFT-JUSTIFIED.
  WRITE: AT  A3   SY-VLINE.
  CLEAR L8.
  MOVE &3 TO L8.
  IF &3 < 0.
    CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
       CHANGING
          VALUE   = L8
     EXCEPTIONS
         OTHERS  = 1.
  ENDIF.
  SHIFT L8 LEFT DELETING LEADING SPACE.
  WRITE: AT  B3   L8 LEFT-JUSTIFIED.
  WRITE: AT  A4   SY-VLINE.
  CLEAR L8.
  MOVE &4 TO L8.
  IF &4 < 0.
    CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
       CHANGING
          VALUE   = L8
     EXCEPTIONS
         OTHERS  = 1.
  ENDIF.
  SHIFT L8 LEFT DELETING LEADING SPACE.
  WRITE: AT  B4   L8 LEFT-JUSTIFIED.
  CLEAR L8.
  MOVE &5 TO L8.
  IF &5 < 0.
    CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
       CHANGING
          VALUE   = L8
     EXCEPTIONS
         OTHERS  = 1.
  ENDIF.
  SHIFT L8 LEFT DELETING LEADING SPACE.
  WRITE: AT  A5   SY-VLINE.
  WRITE: AT  B5   L8 LEFT-JUSTIFIED.
  WRITE: AT  A6   SY-VLINE.
  WRITE: AT  B6   &6 LEFT-JUSTIFIED.
  WRITE: AT  A7   SY-VLINE.
  CLEAR L8.
  MOVE &7 TO L8.
  IF &7 < 0.
    CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
       CHANGING
          VALUE   = L8
     EXCEPTIONS
         OTHERS  = 1.
  ENDIF.
  SHIFT L8 LEFT DELETING LEADING SPACE.
  WRITE: AT  B7   L8 LEFT-JUSTIFIED.
  WRITE: AT  A8   SY-VLINE.
  CLEAR L8.
  MOVE &8 TO L8.
  IF &8 < 0.
    CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
       CHANGING
          VALUE   = L8
     EXCEPTIONS
         OTHERS  = 1.
  ENDIF.
  SHIFT L8 LEFT DELETING LEADING SPACE.
  WRITE: AT  B8   L8 LEFT-JUSTIFIED.
  WRITE: AT  A9   SY-VLINE.
  CLEAR L8.
  MOVE &9 TO L8.
  IF &9 < 0.
    CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
       CHANGING
          VALUE   = L8
     EXCEPTIONS
         OTHERS  = 1.
  ENDIF.
  SHIFT L8 LEFT DELETING LEADING SPACE.
  WRITE: AT  B9   L8 LEFT-JUSTIFIED.
END-OF-DEFINITION.

DEFINE GRID11.
  WRITE: AT  A10   SY-VLINE.
  CLEAR L8.
  MOVE &1 TO L8.
  IF &1 < 0.
    CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
       CHANGING
          VALUE   = L8
     EXCEPTIONS
         OTHERS  = 1.
  ENDIF.
  SHIFT L8 LEFT DELETING LEADING SPACE.
  WRITE: AT  B10   L8 LEFT-JUSTIFIED.
  WRITE: AT  A11   SY-VLINE.
  CLEAR L8.
  MOVE &2 TO L8.
  IF &2 < 0.
    CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
       CHANGING
          VALUE   = L8
     EXCEPTIONS
         OTHERS  = 1.
  ENDIF.
  SHIFT L8 LEFT DELETING LEADING SPACE.
  WRITE: AT  B11   L8 LEFT-JUSTIFIED.
  WRITE: AT  A12   SY-VLINE.
END-OF-DEFINITION.

DEFINE GRID2.
  WRITE: AT /A1   SY-VLINE.
  WRITE: AT  B1   &1  LEFT-JUSTIFIED.
  WRITE: AT  A2   SY-VLINE.
  WRITE: AT  B2   &2  LEFT-JUSTIFIED.
  WRITE: AT  A3   SY-VLINE.
  WRITE: AT  B3   &3 LEFT-JUSTIFIED.
  WRITE: AT  A4   SY-VLINE.
  WRITE: AT  B4   &4 LEFT-JUSTIFIED.
  WRITE: AT  A5   SY-VLINE.
  WRITE: AT  B5   &5 LEFT-JUSTIFIED.
  WRITE: AT  A6   SY-VLINE.
  WRITE: AT  B6   &6 LEFT-JUSTIFIED.
  WRITE: AT  A7   SY-VLINE.

  WRITE: AT  B7   &7 LEFT-JUSTIFIED.
  WRITE: AT  A8   SY-VLINE.
  WRITE: AT  B8   &8 LEFT-JUSTIFIED.
  WRITE: AT  A9   SY-VLINE.
  WRITE: AT  B9   &9 LEFT-JUSTIFIED.
END-OF-DEFINITION.

DEFINE GRID22.
  WRITE: AT  A10   SY-VLINE.
  WRITE: AT  B10   &1 LEFT-JUSTIFIED.
  WRITE: AT  A11   SY-VLINE.
  WRITE: AT  B11   &2 LEFT-JUSTIFIED.
  WRITE: AT  A12   SY-VLINE.
END-OF-DEFINITION.
************************************************************************
*  SELECTION SCREEN : 定义报表筛选条件
************************************************************************
*确定过滤参数
SELECTION-SCREEN BEGIN OF BLOCK BLK_001 WITH FRAME. TITLE BLK_001 .
    PARAMETERS : P_BUKRS LIKE GLT0-BUKRS OBLIGATORY MEMORY ID 013_1. "公司代码
    PARAMETERS : P_RYEAR(4) TYPE C OBLIGATORY MEMORY ID 013_2.       "报表年度
    PARAMETERS : P_MONAT(2) TYPE C OBLIGATORY MEMORY ID 013_3.       "报表期间
SELECTION-SCREEN END OF BLOCK BLK_001.

*选择报表类型
SELECTION-SCREEN BEGIN OF BLOCK BLK_002 WITH FRAME. TITLE BLK_002 .
PARAMETERS: P_REPORT RADIOBUTTON GROUP R1 DEFAULT 'X',
            P_BQ RADIOBUTTON GROUP R1,
            P_BN RADIOBUTTON GROUP R1,
            P_JG_BQ RADIOBUTTON GROUP R1,
            P_KM RADIOBUTTON GROUP R1.
SELECTION-SCREEN END OF BLOCK BLK_002.

*后台相关处理
SELECTION-SCREEN BEGIN OF BLOCK BLK_003 WITH FRAME. TITLE BLK_003 .
PARAMETERS: P_QT RADIOBUTTON GROUP R2,        "前台运行
            P_SHOW RADIOBUTTON GROUP R2.      "显示后台结果
SELECTION-SCREEN END OF BLOCK BLK_003.

*===============================事    件===============================*
************************************************************************
* INITIALIZATION.启动程序开始执行
************************************************************************
INITIALIZATION.
  BLK_001 = '检索参数'.
  BLK_002 = '报表类型'.
  BLK_003 = '运行类型'.

  PERFORM. SUB_INI.
  P_RYEAR = SY-DATUM(4).       "会计年度
  P_RYEAR_L = P_RYEAR - 1.
************************************************************************
* 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.    "每月天数判断

  IF P_QT = 'X'.
    PERFORM. F_READ_DATA_GLT0.       "去GLT0
    IF P_BUKRS = '0999'.
      PERFORM. F_READ_DATA_GLT0_999. "取0999 的 GLT0
    ENDIF.
    PERFORM. F_READ_DATA_XS.         "去销售订单数据
    PERFORM. F_CHANGE.         "去负号
    PERFORM. SUB_TOTAL.        "最终数据合计及总计
  ELSEIF P_SHOW = 'X'.
    PERFORM. F_GET_HT.
  ENDIF.

  PERFORM. SUB_JS.           "计算百分比
***********************************************67*************************
* END OF SELECTION
************************************************************************
END-OF-SELECTION.

  IF P_REPORT = 'X'.
    PERFORM. F_PRINT_REPORT.
  ELSE.
    PERFORM. F_PRINT_ALV.
  ENDIF.
************************************************************************
* 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.
DATA: S_DATE LIKE SY-DATUM.
      S_DATE = SY-DATUM - 60.

  IF STRLEN( P_MONAT ) = 1.
    CONCATENATE '0' P_MONAT INTO P_MONAT.
  ENDIF.
  CONCATENATE P_RYEAR P_MONAT '01' INTO L_DATE.
  IF L_DATE <= '20050201'.
    MESSAGE E001.    "不能运行该期间的报表!
  ENDIF.
  IF P_QT = 'X' AND L_DATE(6) < S_DATE(6) AND P_BUKRS <> '6000' "6000公司暂时不限制 2007.07.05
     AND P_REPORT = 'X' AND SY-UNAME <> 'IT'.
    MESSAGE E006 WITH S_DATE(6).    "禁止在前台再运行小于S_DATE(6)的期间报表,但可后台显示
  ENDIF.
*  IF P_QT = 'X' AND L_DATE < '20070101' .
*     Message E005.    "不能运行06年的期间的报表!
*  ENDIF.
  IF ( P_MONAT < '01' ) OR ( P_MONAT > '16' ).
    MESSAGE E000.    "该会计期间不存在!
  ENDIF.
ENDFORM.                    " F_CHECK_INPUT
*&---------------------------------------------------------------------*
*从数据库中读取数据,填充报表输出时所用的内表
*&---------------------------------------------------------------------*
FORM. F_READ_DATA_GLT0 .
PERFORM. GET_BN_GLT0.
PERFORM. GET_QN_GLT0.
ENDFORM.                    " F_READ_DATA
*&---------------------------------------------------------------------*
*&      去负号
*&---------------------------------------------------------------------*
FORM. F_CHANGE.
*本月和本年累计
*差异
ITAB1-CLCBCY = 0 - ITAB1-CLCBCY.
ITAB6-CLCBCY = 0 - ITAB6-CLCBCY.
ITAB1-SCCBCY = 0 - ITAB1-SCCBCY.
ITAB6-SCCBCY = 0 - ITAB6-SCCBCY.
*ITAB1-JGCGTZ = 0 - ITAB1-JGCGTZ.
*ITAB6-JGCGTZ = 0 - ITAB6-JGCGTZ.

*本月数
*ITAB1-QTYWSR = 0 - ITAB1-QTYWSR.
ITAB1-QTYWZC = 0 - ITAB1-QTYWZC.
ITAB1-YYWSR = 0 - ITAB1-YYWSR.
ITAB1-PTSR = 0 - ITAB1-PTSR.
ITAB1-JTSR = 0 - ITAB1-JTSR.
ITAB1-JTLXSR = 0 - ITAB1-JTLXSR.
*ITAB1-SYDZ = 0 - ITAB1-SYDZ.

*本年累计数
*ITAB6-QTYWSR = 0 - ITAB6-QTYWSR.
ITAB6-QTYWZC = 0 - ITAB6-QTYWZC.
ITAB6-YYWSR = 0 - ITAB6-YYWSR.
ITAB6-PTSR = 0 - ITAB6-PTSR.
ITAB6-JTSR = 0 - ITAB6-JTSR.
ITAB6-JTLXSR = 0 - ITAB6-JTLXSR.
*ITAB6-SYDZ = 0 - ITAB6-SYDZ.

*上年本月和上年累计
*差异
ITAB3-CLCBCY = 0 - ITAB3-CLCBCY.
ITAB8-CLCBCY = 0 - ITAB8-CLCBCY.
ITAB3-SCCBCY = 0 - ITAB3-SCCBCY.
ITAB8-SCCBCY = 0 - ITAB8-SCCBCY.
*ITAB3-JGCGTZ = 0 - ITAB3-JGCGTZ.
*ITAB8-JGCGTZ = 0 - ITAB8-JGCGTZ.

*本月数
*ITAB1-QTYWSR = 0 - ITAB1-QTYWSR.
ITAB3-QTYWZC = 0 - ITAB3-QTYWZC.
ITAB3-YYWSR = 0 - ITAB3-YYWSR.
ITAB3-PTSR = 0 - ITAB3-PTSR.
ITAB3-JTSR = 0 - ITAB3-JTSR.
ITAB3-JTLXSR = 0 - ITAB3-JTLXSR.
*ITAB3-SYDZ = 0 - ITAB3-SYDZ.

*去年累计数
*ITAB6-QTYWSR = 0 - ITAB6-QTYWSR.
ITAB8-QTYWZC = 0 - ITAB8-QTYWZC.
ITAB8-YYWSR = 0 - ITAB8-YYWSR.
ITAB8-PTSR = 0 - ITAB8-PTSR.
ITAB8-JTSR = 0 - ITAB8-JTSR.
ITAB8-JTLXSR = 0 - ITAB8-JTLXSR.
*ITAB8-SYDZ = 0 - ITAB8-SYDZ.

ENDFORM.
*&---------------------------------------------------------------------*
*&      最终数据合计及总计
*&---------------------------------------------------------------------*
FORM. SUB_TOTAL.
*计算本年
*处理ITAB1本期
  "7产品销售毛利 1-2-3-4-5-8
  ITAB1-CPXSML = ITAB1-CPXSSR - ITAB1-CLCB  - ITAB1-CLCBCY - ITAB1-SCCBCY
               - ITAB1-JGCGTZ - ITAB1-CPXSSJ - ITAB1-YTCKSJ.

  "11营业费用合计
  ITAB1-YYFYHJ = ITAB1-XSFY + ITAB1-GLFY + ITAB1-CWFY.

  "14其它支出合计
  ITAB1-QTYWZCHJ = ITAB1-QTYWZC + ITAB1-YYWZC.

  "17其它收入合计
  ITAB1-QTYWSRHJ = ITAB1-QTYWSR + ITAB1-YYWSR + ITAB1-PTSR.

  "18税前净利润
  ITAB1-SQJLR = ITAB1-CPXSML - ITAB1-YYFYHJ - ITAB1-QTYWZCHJ + ITAB1-QTYWSRHJ + ITAB1-SYDZ.

  "20净利润(公司层)
  ITAB1-JLR = ITAB1-SQJLR - ITAB1-SDS.

  "29净利润(集团层)
  ITAB1-JTZLR = ITAB1-JTSR - ITAB1-JTCB - ITAB1-JTSJFJ + ITAB1-JTLXSR - ITAB1-JTLXZC.

*处理ITAB6本年累计
  "7产品销售毛利 1-2-3-4-5-8
  ITAB6-CPXSML = ITAB6-CPXSSR - ITAB6-CLCB  - ITAB6-CLCBCY - ITAB6-SCCBCY
               - ITAB6-JGCGTZ - ITAB6-CPXSSJ - ITAB6-YTCKSJ.

  "11营业费用合计
  ITAB6-YYFYHJ = ITAB6-XSFY + ITAB6-GLFY + ITAB6-CWFY.

  "14其他支出合计
  ITAB6-QTYWZCHJ = ITAB6-QTYWZC + ITAB6-YYWZC.

  "17其他收入合计
  ITAB6-QTYWSRHJ = ITAB6-QTYWSR + ITAB6-YYWSR + ITAB6-PTSR.

  "18税前净利润
  ITAB6-SQJLR = ITAB6-CPXSML - ITAB6-YYFYHJ - ITAB6-QTYWZCHJ + ITAB6-QTYWSRHJ + ITAB6-SYDZ.

  "20净利润(公司层)
  ITAB6-JLR = ITAB6-SQJLR - ITAB6-SDS.

 "29净利润(集团层)
  ITAB6-JTZLR = ITAB6-JTSR - ITAB6-JTCB - ITAB6-JTSJFJ + ITAB6-JTLXSR - ITAB6-JTLXZC.

*计算去年
*处理ITAB3本期
  "7产品销售毛利 1-2-3-4-5-8
  ITAB3-CPXSML = ITAB3-CPXSSR - ITAB3-CLCB  - ITAB3-CLCBCY - ITAB3-SCCBCY
               - ITAB3-JGCGTZ - ITAB3-CPXSSJ - ITAB3-YTCKSJ.

  "11营业费用合计
  ITAB3-YYFYHJ = ITAB3-XSFY + ITAB3-GLFY + ITAB3-CWFY.

  "14其他指出合计
  ITAB3-QTYWZCHJ = ITAB3-QTYWZC + ITAB3-YYWZC.

  "17其他收入合计
  ITAB3-QTYWSRHJ = ITAB3-QTYWSR + ITAB3-YYWSR + ITAB3-PTSR.

  "18税前净利润
  ITAB3-SQJLR = ITAB3-CPXSML - ITAB3-YYFYHJ - ITAB3-QTYWZCHJ + ITAB3-QTYWSRHJ + ITAB3-SYDZ.

  "20净利润(公司层)
  ITAB3-JLR = ITAB3-SQJLR - ITAB3-SDS.

  "29净利润(集团层)
  ITAB3-JTZLR = ITAB3-JTSR - ITAB3-JTCB - ITAB3-JTSJFJ + ITAB3-JTLXSR - ITAB3-JTLXZC.

*处理ITAB6本年累计
  "7产品销售毛利 1-2-3-4-5-8
  ITAB8-CPXSML = ITAB8-CPXSSR - ITAB8-CLCB  - ITAB8-CLCBCY - ITAB8-SCCBCY
               - ITAB8-JGCGTZ - ITAB8-CPXSSJ - ITAB8-YTCKSJ.

  "11营业费用合计
  ITAB8-YYFYHJ = ITAB8-XSFY + ITAB8-GLFY + ITAB8-CWFY.

  "14其他指出合计
  ITAB8-QTYWZCHJ = ITAB8-QTYWZC + ITAB8-YYWZC.

  "17其他收入合计
  ITAB8-QTYWSRHJ = ITAB8-QTYWSR + ITAB8-YYWSR + ITAB8-PTSR.

  "18税前净利润
  ITAB8-SQJLR = ITAB8-CPXSML - ITAB8-YYFYHJ - ITAB8-QTYWZCHJ + ITAB8-QTYWSRHJ + ITAB8-SYDZ.

  "20净利润(公司层)
  ITAB8-JLR = ITAB8-SQJLR - ITAB8-SDS.

  "29净利润(集团层)
  ITAB8-JTZLR = ITAB8-JTSR - ITAB8-JTCB - ITAB8-JTSJFJ + ITAB8-JTLXSR - ITAB8-JTLXZC.

ENDFORM.
*&---------------------------------------------------------------------*
*普通报表格式的打印
*&---------------------------------------------------------------------*
FORM. F_PRINT_REPORT.
GRID1 ITAB1-CPXSSR ITAB2-CPXSSR ITAB3-CPXSSR ITAB4-CPXSSR ITAB5-CPXSSR
      '产品销售收入' ITAB6-CPXSSR ITAB7-CPXSSR ITAB8-CPXSSR.
GRID11 ITAB9-CPXSSR ITAB10-CPXSSR.
ULINE.

GRID1 ITAB1-CLCB ITAB2-CLCB ITAB3-CLCB ITAB4-CLCB ITAB5-CLCB
      '产品销售成本' ITAB6-CLCB ITAB7-CLCB ITAB8-CLCB.
GRID11 ITAB9-CLCB ITAB10-CLCB.
ULINE.

GRID1 ITAB1-CLCBCY ITAB2-CLCBCY ITAB3-CLCBCY ITAB4-CLCBCY ITAB5-CLCBCY
      '材料成本差异' ITAB6-CLCBCY ITAB7-CLCBCY ITAB8-CLCBCY.
GRID11 ITAB9-CLCBCY ITAB10-CLCBCY.
ULINE.

GRID1 ITAB1-SCCBCY ITAB2-SCCBCY ITAB3-SCCBCY ITAB4-SCCBCY ITAB5-SCCBCY
      '生产成本差异' ITAB6-SCCBCY ITAB7-SCCBCY ITAB8-SCCBCY.
GRID11 ITAB9-SCCBCY ITAB10-SCCBCY.
ULINE.

GRID1 ITAB1-JGCGTZ ITAB2-JGCGTZ ITAB3-JGCGTZ ITAB4-JGCGTZ ITAB5-JGCGTZ
      '价格重估调整' ITAB6-JGCGTZ ITAB7-JGCGTZ ITAB8-JGCGTZ.
GRID11 ITAB9-JGCGTZ ITAB10-JGCGTZ.
ULINE.

GRID1 ITAB1-CPXSSJ ITAB2-CPXSSJ ITAB3-CPXSSJ ITAB4-CPXSSJ ITAB5-CPXSSJ
      '产品销售税金及附加' ITAB6-CPXSSJ ITAB7-CPXSSJ ITAB8-CPXSSJ.
GRID11 ITAB9-CPXSSJ ITAB10-CPXSSJ.
ULINE.

GRID1 ITAB1-YTCKSJ ITAB2-YTCKSJ ITAB3-YTCKSJ ITAB4-YTCKSJ ITAB5-YTCKSJ
      '预提当月出口税金' ITAB6-YTCKSJ ITAB7-YTCKSJ ITAB8-YTCKSJ.
GRID11 ITAB9-YTCKSJ ITAB10-YTCKSJ.
ULINE.

GRID1 ITAB1-CPXSML ITAB2-CPXSML ITAB3-CPXSML ITAB4-CPXSML ITAB5-CPXSML
      '产品销售毛利' ITAB6-CPXSML ITAB7-CPXSML ITAB8-CPXSML.
GRID11 ITAB9-CPXSML ITAB10-CPXSML.
ULINE.

GRID1 ITAB1-XSFY ITAB2-XSFY ITAB3-XSFY ITAB4-XSFY ITAB5-XSFY
      '销售费用' ITAB6-XSFY ITAB7-XSFY ITAB8-XSFY.
GRID11 ITAB9-XSFY ITAB10-XSFY.
ULINE.

GRID1 ITAB1-GLFY ITAB2-GLFY ITAB3-GLFY ITAB4-GLFY ITAB5-GLFY
      '管理费用' ITAB6-GLFY ITAB7-GLFY ITAB8-GLFY.
GRID11 ITAB9-GLFY ITAB10-GLFY.
ULINE.

GRID1 ITAB1-CWFY ITAB2-CWFY ITAB3-CWFY ITAB4-CWFY ITAB5-CWFY
      '财务费用' ITAB6-CWFY ITAB7-CWFY ITAB8-CWFY.
GRID11 ITAB9-CWFY ITAB10-CWFY.
ULINE.

GRID1 ITAB1-YYFYHJ ITAB2-YYFYHJ ITAB3-YYFYHJ ITAB4-YYFYHJ ITAB5-YYFYHJ
      '营业费用合计' ITAB6-YYFYHJ ITAB7-YYFYHJ ITAB8-YYFYHJ.
GRID11 ITAB9-YYFYHJ ITAB10-YYFYHJ.
ULINE.

GRID1 ITAB1-QTYWZC ITAB2-QTYWZC ITAB3-QTYWZC ITAB4-QTYWZC ITAB5-QTYWZC
      '其它业务支出' ITAB6-QTYWZC ITAB7-QTYWZC ITAB8-QTYWZC.
GRID11 ITAB9-QTYWZC ITAB10-QTYWZC.
ULINE.

GRID1 ITAB1-YYWZC ITAB2-YYWZC ITAB3-YYWZC ITAB4-YYWZC ITAB5-YYWZC
      '营业外支出' ITAB6-YYWZC ITAB7-YYWZC ITAB8-YYWZC.
GRID11 ITAB9-YYWZC ITAB10-YYWZC.
ULINE.

GRID1 ITAB1-QTYWZCHJ ITAB2-QTYWZCHJ ITAB3-QTYWZCHJ ITAB4-QTYWZCHJ ITAB5-QTYWZCHJ
      '其它支出合计' ITAB6-QTYWZCHJ ITAB7-QTYWZCHJ ITAB8-QTYWZCHJ.
GRID11 ITAB9-QTYWZCHJ ITAB10-QTYWZCHJ.
ULINE.

GRID1 ITAB1-QTYWSR ITAB2-QTYWSR ITAB3-QTYWSR ITAB4-QTYWSR ITAB5-QTYWSR
      '其它业务收入' ITAB6-QTYWSR ITAB7-QTYWSR ITAB8-QTYWSR.
GRID11 ITAB9-QTYWSR ITAB10-QTYWSR.
ULINE.

GRID1 ITAB1-YYWSR ITAB2-YYWSR ITAB3-YYWSR ITAB4-YYWSR ITAB5-YYWSR
      '营业外收入' ITAB6-YYWSR ITAB7-YYWSR ITAB8-YYWSR.
GRID11 ITAB9-YYWSR ITAB10-YYWSR.
ULINE.

GRID1 ITAB1-PTSR ITAB2-PTSR ITAB3-PTSR ITAB4-PTSR ITAB5-PTSR
      '补贴收入' ITAB6-PTSR ITAB7-PTSR ITAB8-PTSR.
GRID11 ITAB9-PTSR ITAB10-PTSR.
ULINE.

GRID1 ITAB1-QTYWSRHJ ITAB2-QTYWSRHJ ITAB3-QTYWSRHJ ITAB4-QTYWSRHJ ITAB5-QTYWSRHJ
      '其它业务收入合计' ITAB6-QTYWSRHJ ITAB7-QTYWSRHJ ITAB8-QTYWSRHJ.
GRID11 ITAB9-QTYWSRHJ ITAB10-QTYWSRHJ.
ULINE.

GRID1 ITAB1-SYDZ ITAB2-SYDZ ITAB3-SYDZ ITAB4-SYDZ ITAB5-SYDZ
      '以前年度损益调整' ITAB6-SYDZ ITAB7-SYDZ ITAB8-SYDZ.
GRID11 ITAB9-SYDZ ITAB10-SYDZ.
ULINE.

GRID1 ITAB1-SQJLR ITAB2-SQJLR ITAB3-SQJLR ITAB4-SQJLR ITAB5-SQJLR
      '税前净利润' ITAB6-SQJLR ITAB7-SQJLR ITAB8-SQJLR.
GRID11 ITAB9-SQJLR ITAB10-SQJLR.
ULINE.

GRID1 ITAB1-SDS ITAB2-SDS ITAB3-SDS ITAB4-SDS ITAB5-SDS
      '所得税' ITAB6-SDS ITAB7-SDS ITAB8-SDS.
GRID11 ITAB9-SDS ITAB10-SDS.
ULINE.

GRID1 ITAB1-JLR ITAB2-JLR ITAB3-JLR ITAB4-JLR ITAB5-JLR
      '净利润(公司层)' ITAB6-JLR ITAB7-JLR ITAB8-JLR.
GRID11 ITAB9-JLR ITAB10-JLR.
ULINE.

GRID1 ITAB1-JTSR ITAB2-JTSR ITAB3-JTSR ITAB4-JTSR ITAB5-JTSR
      '集团层收入' ITAB6-JTSR ITAB7-JTSR ITAB8-JTSR.
GRID11 ITAB9-JTSR ITAB10-JTSR.
ULINE.

GRID1 ITAB1-JTCB ITAB2-JTCB ITAB3-JTCB ITAB4-JTCB ITAB5-JTCB
      '集团层成本' ITAB6-JTCB ITAB7-JTCB ITAB8-JTCB.
GRID11 ITAB9-JTCB ITAB10-JTCB.
ULINE.

GRID1 ITAB1-JTSJFJ ITAB2-JTSJFJ ITAB3-JTSJFJ ITAB4-JTSJFJ ITAB5-JTSJFJ
      '集团层税金及附加' ITAB6-JTSJFJ ITAB7-JTSJFJ ITAB8-JTSJFJ.
GRID11 ITAB9-JTSJFJ ITAB10-JTSJFJ.
ULINE.

GRID1 ITAB1-JTLXSR ITAB2-JTLXSR ITAB3-JTLXSR ITAB4-JTLXSR ITAB5-JTLXSR
      '集团层利息收入' ITAB6-JTLXSR ITAB7-JTLXSR ITAB8-JTLXSR.
GRID11 ITAB9-JTLXSR ITAB10-JTLXSR.
ULINE.

GRID1 ITAB1-JTLXZC ITAB2-JTLXZC ITAB3-JTLXZC ITAB4-JTLXZC ITAB5-JTLXZC
      '集团层利息支出' ITAB6-JTLXZC ITAB7-JTLXZC ITAB8-JTLXZC.
GRID11 ITAB9-JTLXZC ITAB10-JTLXZC.
ULINE.

GRID1 ITAB1-JTZLR ITAB2-JTZLR ITAB3-JTZLR ITAB4-JTZLR ITAB5-JTZLR
      '净利润(集团层)' ITAB6-JTZLR ITAB7-JTZLR ITAB8-JTZLR.
GRID11 ITAB9-JTZLR ITAB10-JTZLR.
ULINE.

PERFORM. SUB_BOTTOM.

*-将本期值保存到ZFI01中.
  PERFORM. F_SAVE.
*-将数值保存到ZFI04中.
  PERFORM. F_SAVE_HT.
ENDFORM.                     " F_PRINT_REPORT
*&---------------------------------------------------------------------*
*&      将本期值保存到ZFI01中
*&---------------------------------------------------------------------*
FORM. F_SAVE.
DATA: FLAG TYPE I,
      L_DATE LIKE LIKP-KODAT,
      L_RYEAR(4),
      L_MONAT(2),
      L_DAY(2),
      L_MOD TYPE I.

  SELECT *
    FROM ZFI01
    INTO CORRESPONDING FIELDS OF TABLE IT_PRINT_006
    WHERE WERKS = P_BUKRS AND
          RYEAR = P_RYEAR AND
          RPMAX = P_MONAT.

  FLAG = 0.
  LOOP AT IT_PRINT_006.
    UPDATE ZFI01
      SET AMOUNT = ITAB1-JLR
          JGCGTZ = ITAB1-JGCGTZ
          FLAG = '1'
          AEDAT = SY-DATUM
          AENAM = SY-UNAME
      WHERE WERKS = P_BUKRS AND
            RYEAR = P_RYEAR AND
            RPMAX = P_MONAT.
    FLAG = 1.
  ENDLOOP.

  "整理日期
  L_RYEAR = P_RYEAR.
  L_MONAT = P_MONAT.

  IF L_MONAT = '04' OR L_MONAT = '06' OR
    L_MONAT = '09' OR L_MONAT = '11'.
    L_DAY = '30'.
  ELSEIF L_MONAT = '02'.
    L_MOD = L_RYEAR MOD 4.
    IF L_MOD = 0.
      L_DAY = '29'.
    ELSE.
      L_DAY = '28'.
    ENDIF.
  ELSE.
    L_DAY = '31'.
  ENDIF.

  CONCATENATE L_RYEAR L_MONAT L_DAY INTO L_DATE.

  CLEAR IT_PRINT_006.
  REFRESH IT_PRINT_006.
  IT_PRINT_006-FLAG = '1'.         "1表示对内损益表,2表示合并损益表
  IT_PRINT_006-WERKS = P_BUKRS.
  IT_PRINT_006-RYEAR = P_RYEAR.
  IT_PRINT_006-RPMAX = P_MONAT.
  IT_PRINT_006-PODAT = L_DATE.
  IT_PRINT_006-AMOUNT = ITAB1-JLR.
  IT_PRINT_006-JGCGTZ = ITAB1-JGCGTZ.
  IT_PRINT_006-TEXT = ''.
  IT_PRINT_006-ERDAT = SY-DATUM.
  IT_PRINT_006-AEDAT = SY-DATUM.
  IT_PRINT_006-ERNAM = SY-UNAME.
  IT_PRINT_006-AENAM = SY-UNAME.

  IF FLAG = 0.
    INSERT INTO ZFI01
      VALUES IT_PRINT_006 .
  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*&      将本期值保存到ZFI04中
*&记录类型RRCTY:5为本月数;6为去年同期数;7为本年累计数;8为去年同期数;
*&---------------------------------------------------------------------*
FORM. F_SAVE_HT.
  PERFORM. F_SAVE_SUB USING '5'.
  PERFORM. F_SAVE_SUB USING '6'.
  PERFORM. F_SAVE_SUB USING '7'.
  PERFORM. F_SAVE_SUB USING '8'.
ENDFORM.
*&---------------------------------------------------------------------*
*&      将本期值保存到ZFI04中(SUB)
*&---------------------------------------------------------------------*
FORM. F_SAVE_SUB USING PP_RRCTY.
DATA: FLAG TYPE I.
DATA: PP_ITAB LIKE ITAB1 OCCURS 10 WITH HEADER LINE.

  CLEAR PP_ITAB. REFRESH PP_ITAB.
  CASE PP_RRCTY.
    WHEN '5'.
      MOVE ITAB1 TO PP_ITAB.
    WHEN '6'.
      MOVE ITAB3 TO PP_ITAB.
    WHEN '7'.
      MOVE ITAB6 TO PP_ITAB.
    WHEN '8'.
      MOVE ITAB8 TO PP_ITAB.
  ENDCASE.

  CLEAR ITAB_HT.
  REFRESH ITAB_HT.
  SELECT *
    FROM ZFI04
    INTO CORRESPONDING FIELDS OF TABLE ITAB_HT
    WHERE BUKRS = P_BUKRS AND
          RYEAR = P_RYEAR AND
          RPMAX = P_MONAT AND
          RRCTY = PP_RRCTY.

  FLAG = 0.
  LOOP AT ITAB_HT.
    UPDATE ZFI04
       SET CPXSSR = PP_ITAB-CPXSSR
           CLCB = PP_ITAB-CLCB
           CLCBCY = PP_ITAB-CLCBCY
           SCCBCY = PP_ITAB-SCCBCY
           CPXSSJ = PP_ITAB-CPXSSJ
           YTCKSJ = PP_ITAB-YTCKSJ
           CPXSML = PP_ITAB-CPXSML
           XSFY = PP_ITAB-XSFY
           GLFY = PP_ITAB-GLFY
           CWFY = PP_ITAB-CWFY
           YYFYHJ = PP_ITAB-YYFYHJ
           QTYWZC = PP_ITAB-QTYWZC
           YYWZC = PP_ITAB-YYWZC
           QTYWZCHJ = PP_ITAB-QTYWZCHJ
           QTYWSR = PP_ITAB-QTYWSR
           YYWSR = PP_ITAB-YYWSR
           PTSR = PP_ITAB-PTSR
           QTYWSRHJ = PP_ITAB-QTYWSRHJ
           SYDZ = PP_ITAB-SYDZ
           SQJLR = PP_ITAB-SQJLR
           SDS = PP_ITAB-SDS
           JLR = PP_ITAB-JLR
           JGCGTZ = PP_ITAB-JGCGTZ
           JTSR = PP_ITAB-JTSR
           JTCB = PP_ITAB-JTCB
           JTSJFJ = PP_ITAB-JTSJFJ
           JTLXSR = PP_ITAB-JTLXSR
           JTLXZC = PP_ITAB-JTLXZC
           JTZLR = PP_ITAB-JTZLR
           TEXT = ''
           AEDAT = SY-DATUM
           AENAM = SY-UNAME
     WHERE BUKRS = P_BUKRS AND
           RYEAR = P_RYEAR AND
           RPMAX = P_MONAT AND
           RRCTY = PP_RRCTY.
     FLAG = 1.
  ENDLOOP.

  IF FLAG = 0.
      ITAB_HT-RRCTY = PP_RRCTY.
      ITAB_HT-BUKRS = P_BUKRS.
      ITAB_HT-RYEAR = P_RYEAR.
      ITAB_HT-RPMAX = P_MONAT.
      ITAB_HT-CPXSSR = PP_ITAB-CPXSSR.
      ITAB_HT-CLCB = PP_ITAB-CLCB.
      ITAB_HT-CLCBCY = PP_ITAB-CLCBCY.
      ITAB_HT-SCCBCY = PP_ITAB-SCCBCY.
      ITAB_HT-CPXSSJ = PP_ITAB-CPXSSJ.
      ITAB_HT-YTCKSJ = PP_ITAB-YTCKSJ.
      ITAB_HT-CPXSML = PP_ITAB-CPXSML.
      ITAB_HT-XSFY = PP_ITAB-XSFY.
      ITAB_HT-GLFY = PP_ITAB-GLFY.
      ITAB_HT-CWFY = PP_ITAB-CWFY.
      ITAB_HT-YYFYHJ = PP_ITAB-YYFYHJ.
      ITAB_HT-QTYWZC = PP_ITAB-QTYWZC.
      ITAB_HT-YYWZC = PP_ITAB-YYWZC.
      ITAB_HT-QTYWZCHJ = PP_ITAB-QTYWZCHJ.
      ITAB_HT-QTYWSR = PP_ITAB-QTYWSR.
      ITAB_HT-YYWSR = PP_ITAB-YYWSR.
      ITAB_HT-PTSR = PP_ITAB-PTSR.
      ITAB_HT-QTYWSRHJ = PP_ITAB-QTYWSRHJ.
      ITAB_HT-SYDZ = PP_ITAB-SYDZ.
      ITAB_HT-SQJLR = PP_ITAB-SQJLR.
      ITAB_HT-SDS = PP_ITAB-SDS.
      ITAB_HT-JLR = PP_ITAB-JLR.
      ITAB_HT-JGCGTZ = PP_ITAB-JGCGTZ.
      ITAB_HT-JTSR = PP_ITAB-JTSR.
      ITAB_HT-JTCB = PP_ITAB-JTCB.
      ITAB_HT-JTSJFJ = PP_ITAB-JTSJFJ.
      ITAB_HT-JTLXSR = PP_ITAB-JTLXSR.
      ITAB_HT-JTLXZC = PP_ITAB-JTLXZC.
      ITAB_HT-JTZLR = PP_ITAB-JTZLR.
      ITAB_HT-TEXT = ''.
      ITAB_HT-ERDAT = SY-DATUM.
      ITAB_HT-ERNAM = SY-UNAME.
      APPEND ITAB_HT.

    INSERT INTO ZFI04
      VALUES ITAB_HT .
  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*&      后台数据显示
*&---------------------------------------------------------------------*
FORM. F_GET_HT.
  PERFORM. F_GET_HT_SUB USING '5'.
  PERFORM. F_GET_HT_SUB USING '6'.
  PERFORM. F_GET_HT_SUB USING '7'.
  PERFORM. F_GET_HT_SUB USING '8'.
ENDFORM.
*&---------------------------------------------------------------------*
*&      后台数据显示
*&---------------------------------------------------------------------*
FORM. F_GET_HT_SUB USING PP_RRCTY.
DATA: PP_ITAB LIKE ITAB1 OCCURS 10 WITH HEADER LINE.

  CLEAR ITAB_HT.  REFRESH ITAB_HT.
  CLEAR PP_ITAB.  REFRESH PP_ITAB.
  SELECT *
    FROM ZFI04
    INTO CORRESPONDING FIELDS OF TABLE ITAB_HT
    WHERE BUKRS = P_BUKRS AND
          RYEAR = P_RYEAR AND
          RPMAX = P_MONAT AND
          RRCTY = PP_RRCTY.

  LOOP AT ITAB_HT.
    PP_ITAB-CPXSSR = ITAB_HT-CPXSSR.
    PP_ITAB-CLCB = ITAB_HT-CLCB.
    PP_ITAB-CLCBCY = ITAB_HT-CLCBCY.
    PP_ITAB-SCCBCY = ITAB_HT-SCCBCY.
    PP_ITAB-CPXSSJ = ITAB_HT-CPXSSJ.
    PP_ITAB-YTCKSJ = ITAB_HT-YTCKSJ.
    PP_ITAB-CPXSML = ITAB_HT-CPXSML.
    PP_ITAB-XSFY = ITAB_HT-XSFY.
    PP_ITAB-GLFY = ITAB_HT-GLFY.
    PP_ITAB-CWFY = ITAB_HT-CWFY.
    PP_ITAB-YYFYHJ = ITAB_HT-YYFYHJ.
    PP_ITAB-QTYWZC = ITAB_HT-QTYWZC.
    PP_ITAB-YYWZC = ITAB_HT-YYWZC.
    PP_ITAB-QTYWZCHJ = ITAB_HT-QTYWZCHJ.
    PP_ITAB-QTYWSR = ITAB_HT-QTYWSR.
    PP_ITAB-YYWSR = ITAB_HT-YYWSR.
    PP_ITAB-PTSR = ITAB_HT-PTSR.
    PP_ITAB-QTYWSRHJ = ITAB_HT-QTYWSRHJ.
    PP_ITAB-SYDZ = ITAB_HT-SYDZ.
    PP_ITAB-SQJLR = ITAB_HT-SQJLR.
    PP_ITAB-SDS = ITAB_HT-SDS.
    PP_ITAB-JLR = ITAB_HT-JLR.
    PP_ITAB-JGCGTZ = ITAB_HT-JGCGTZ.
    PP_ITAB-JTSR = ITAB_HT-JTSR.
    PP_ITAB-JTCB = ITAB_HT-JTCB.
    PP_ITAB-JTSJFJ = ITAB_HT-JTSJFJ.
    PP_ITAB-JTLXSR = ITAB_HT-JTLXSR.
    PP_ITAB-JTLXZC = ITAB_HT-JTLXZC.
    PP_ITAB-JTZLR = ITAB_HT-JTZLR.
    APPEND PP_ITAB.
  ENDLOOP.

  CASE PP_RRCTY.
    WHEN '5'.
      MOVE PP_ITAB TO ITAB1.
    WHEN '6'.
      MOVE PP_ITAB TO ITAB3.
    WHEN '7'.
      MOVE PP_ITAB TO ITAB6.
    WHEN '8'.
      MOVE PP_ITAB TO ITAB8.
  ENDCASE.
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 = '厦门市安坤热水器有限公司'.

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

上一篇: ZR_FI_012
下一篇: ZR_FI_016
请登录后发表评论 登录
全部评论

注册时间:2006-03-01

  • 博文量
    28
  • 访问量
    19575