ITPub博客

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

ZR_FI_014

原创 Linux操作系统 作者:williamzhou 时间:2019-06-16 21:48:05 0 删除 编辑

*===============================基本信息===============================*
* 标题:合并资产负债报表
* 创建日期:2005-01-20       
*===============================定    义===============================*

************************************************************************
* 基本代码
************************************************************************
REPORT ZR_FI_014
NO STANDARD PAGE HEADING
LINE-SIZE  152
MESSAGE-ID ZFI1.

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

************************************************************************
* TABLE: 定义TABLE
************************************************************************
TABLES: T001,  "公司代码
        GLT0,  "总帐科目主记录业务额
        ANLC,  "资产值字段
        MBEW,  "物料评估
        MBEWH, "物料评估:历史
        MLIT,  "物料分类帐凭证: 项目(MR21主记录)
        MLHD,  "物料总帐凭证:标题(MR21)
        MLCR,  "物料分类帐凭证: 价格更改(货币, 价格)(MR21旧价格)
        MLCRP, "物料分类帐凭证: 价格更改(货币, 价格)(MR21新价格)
        MARD,  "物料的仓储位置数据
        MKPF,  "抬头:物料凭证
        MSEG,  "凭证段:物料
        KNA1,  "客户主文件的一般数据
        ZFI01.

************************************************************************
*INTERNAL TABLES
************************************************************************
*定义内表ITAB(作为辅助使用)
DATA: BEGIN OF ITAB OCCURS 10.
        INCLUDE STRUCTURE GLT0.
      DATA: TAMOUNT LIKE GLT0-HSLVT.
DATA: END OF ITAB.

*定义内表ITABS(期未数)
DATA: BEGIN OF ITAB_QM OCCURS 10.
DATA: "流动资产:
      XJ      LIKE GLT0-HSLVT,   "现金
      DQTZ    LIKE GLT0-HSLVT,   "短期投资
      YSPJ    LIKE GLT0-HSLVT,   "应收票据
      YSZK    LIKE GLT0-HSLVT,   "应收帐款
      HZZB    LIKE GLT0-HSLVT,   "减:坏帐准备
      YSZKJE  LIKE GLT0-HSLVT,   "应收帐款净额
      YFZK    LIKE GLT0-HSLVT,   "预付帐款
      YSBTK   LIKE GLT0-HSLVT,   "应收补贴款
      QTYSK   LIKE GLT0-HSLVT,   "其他应收款
      CH      LIKE GLT0-HSLVT,   "存货
      DTFY    LIKE GLT0-HSLVT,   "待摊费用
      ZCLS    LIKE GLT0-HSLVT,   "待处理流动资产净损失
      ZQTZ    LIKE GLT0-HSLVT,   "一年内到期的长期债券投资
      QTLDZC      LIKE GLT0-HSLVT,"其他流动资产
      TOTAL_LDZC  LIKE GLT0-HSLVT,"流动资产合计

      "长期投资:
      CQTZ    LIKE GLT0-HSLVT,   "长期投资
      "固定资产:
      GDZCYZ  LIKE GLT0-HSLVT,   "固定资产原价
      LJZJ    LIKE GLT0-HSLVT,   "减:累计折旧
      GDZCJZ  LIKE GLT0-HSLVT,   "固定资产净值
      GDZCQL  LIKE GLT0-HSLVT,   "固定资产清理
      ZJGC    LIKE GLT0-HSLVT,   "在建工程
      GDZCSS      LIKE GLT0-HSLVT,"待处理固定资产净损失
      TOTAL_GDZC  LIKE GLT0-HSLVT,"固定资产合计

      "无形资产及递延资产:
      WXZC    LIKE GLT0-HSLVT,   "无形资产
      TYZC    LIKE GLT0-HSLVT,   "递延资产
      TOTAL_WXZC    LIKE GLT0-HSLVT,"无形资产及递延资产合计

      "其他长期资产:
      QCCQZC    LIKE GLT0-HSLVT, "其他长期资产
      "递延税项
      TYSXJX    LIKE GLT0-HSLVT, "递延税项借项
      TOTAL_ZC  LIKE GLT0-HSLVT, "资产总计

      "流动负债:
      DQJK    LIKE GLT0-HSLVT,   "短期借款
      YFPJ    LIKE GLT0-HSLVT,   "应付票据
      YIFZK   LIKE GLT0-HSLVT,   "应付帐款
      YUSZK    LIKE GLT0-HSLVT,   "预收帐款
      YFGZ    LIKE GLT0-HSLVT,   "应付工资
      YFFLF   LIKE GLT0-HSLVT,   "应付福利费
      YFGL    LIKE GLT0-HSLVT,   "应付股利
      YJSJ    LIKE GLT0-HSLVT,   "应交税金
      QTYJK   LIKE GLT0-HSLVT,   "其他应交款
      QTYFK   LIKE GLT0-HSLVT,   "其他应付款
      YTFY    LIKE GLT0-HSLVT,   "预提费用
      DQCQFZ  LIKE GLT0-HSLVT,   "一年内到期的长期负债
      QTLDFZ  LIKE GLT0-HSLVT,   "其他流动负债
      TOTAL_LDFZ LIKE GLT0-HSLVT,"流动负债合计

      "长期负债:
      CQJK    LIKE GLT0-HSLVT,   "长期借款
      YFZQ    LIKE GLT0-HSLVT,   "应付债券
      CQYFK   LIKE GLT0-HSLVT,   "长期应付款
      QTCQFZ  LIKE GLT0-HSLVT,   "其他长期负债
      ZFZZJ   LIKE GLT0-HSLVT,   "其中:住房周转金
      TOTAL_CQFZ LIKE GLT0-HSLVT,"长期负债合计

      "递延税项:
      TYSXDX    LIKE GLT0-HSLVT, "递延税项贷项
      TOTAL_FZ  LIKE GLT0-HSLVT, "负债合计

      "所有者权益(或股东权益):
      SSZB    LIKE GLT0-HSLVT,   "实收资本(或股本)
      YGFTZ   LIKE GLT0-HSLVT,   "减:已归还投资
      SSZBJE  LIKE GLT0-HSLVT,   "实收资本(或股本)净额
      ZBGJ    LIKE GLT0-HSLVT,   "资本公积
      YYGJ    LIKE GLT0-HSLVT,   "盈余公积
      GYJ     LIKE GLT0-HSLVT,   "其中:公益金
      WFPLL   LIKE GLT0-HSLVT,   "未分配利润
      TOTAL_QY   LIKE GLT0-HSLVT,"所有者权益合计
      TOTAL_FZQY LIKE GLT0-HSLVT."负债及所有者权益总计
DATA: END OF ITAB_QM.

*定义内表ITAB_NC(年初数)
DATA: ITAB_NC LIKE ITAB_QM OCCURS 10 WITH HEADER LINE.
*定义内表ITAB_NC2005(2005年初数,用于显示,不参加计算)
DATA: ITAB_NC2005 LIKE ITAB_QM OCCURS 10 WITH HEADER LINE.


*定义内表,处理非寄售出退货信息
DATA: BEGIN OF IT_PRINT_001 OCCURS 0.
        DATA FLAG.
        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 KPEIN LIKE VBAP-KPEIN.        "条件定价单位
        DATA AMOUNT LIKE LIPS-NETPR.       "金额

        DATA PRODQTY_C(20).
        DATA AMOUNT_C(20).
        DATA VGBEL LIKE LIPS-VGBEL.         "参考凭证的凭证号(销售订单号)
        DATA VGPOS LIKE LIPS-VGPOS.         "销售和分销凭证的项目号
        DATA KDMAT LIKE LIPS-KDMAT.         "客户物料号
        DATA BSTNK LIKE VBAK-BSTNK.         "采购订单编号
        DATA VTWEG LIKE VBAK-VTWEG.         "分销渠道
        DATA VKORG LIKE VBAK-VKORG.         "公司代码
DATA: END OF IT_PRINT_001.

DATA: IT_PRINT_002 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.


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

*往数据库增加运行日志
  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 LIKE LIPS-NETPR,
      L_AMOUNT_CB LIKE LIPS-NETPR,
      L_TAX TYPE P DECIMALS 2 VALUE '0.17'.
************************************************************************
* 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.

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.

DATA: NAME_LAST LIKE USER_ADDR-NAME_LAST,
      NAME_FIRST LIKE USER_ADDR-NAME_FIRST,
      NAME(16).

DATA: G_DAY(2),
      G_LEN TYPE I,
      G_MOD TYPE I,
      V_KANSW LIKE ANLC-KANSW, "累积购置和生产费用
      V_KNAFA LIKE ANLC-KNAFA, "累计正常折旧
      P_KANSW LIKE ANLC-KANSW, "
      G_DATE1 LIKE LIKP-ERDAT, "年初
      G_DATE2 LIKE LIKP-ERDAT, "本期当月第一天
      G_DATE3 LIKE LIKP-ERDAT, "本期当月最后一天
      G_BUKRS LIKE GLT0-BUKRS, "公司
      G_DATE_1 LIKE LIKP-ERDAT,
      G_DATE_2 LIKE LIKP-ERDAT,
      G_AMOUNT_YSZK LIKE LIPS-NETPR,
      G_AMOUNT_YJSJ LIKE LIPS-NETPR,
      G_AMOUNT_CH LIKE LIPS-NETPR,
      G_PRODNO LIKE LIPS-MATNR,
      G_DATE LIKE LIKP-ERDAT,
      G_PRICE TYPE P DECIMALS 6.
************************************************************************
* DEFINE: 定义宏
************************************************************************
*普通报表格式的输出宏
DEFINE MACRO1.               "画表格
  WRITE: AT /A1   SY-VLINE.
  WRITE: AT  B1   &1.
  WRITE: AT  A2   SY-VLINE.
  WRITE: AT  B2   &2 CENTERED.
  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.
  WRITE: AT  B5   &5.
  WRITE: AT  A6   SY-VLINE.
  WRITE: AT  B6   &6 CENTERED.
  WRITE: AT  A7   SY-VLINE.
  WRITE: AT  B7   &7 RIGHT-JUSTIFIED.
  WRITE: AT  A8   SY-VLINE.
  WRITE: AT  B8   &8 RIGHT-JUSTIFIED.
  WRITE: AT  A9   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 DEFAULT '1000'."公司代码
    PARAMETERS : P_RYEAR(4) TYPE C OBLIGATORY DEFAULT SY-DATUM+0(4)."报表年度
    PARAMETERS : P_MONAT(2) TYPE C OBLIGATORY DEFAULT SY-DATUM+4(2)."报表期间
SELECTION-SCREEN END OF BLOCK BLK_001.


*===============================事    件===============================*
************************************************************************
* INITIALIZATION.启动程序开始执行
************************************************************************
INITIALIZATION.
  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.                "每月天数判断

  IF P_RYEAR = '2005'.
    PERFORM. F_READ_DATA2005.
    PERFORM. F_PRINT_REPORT2005.
  ELSE.
    PERFORM. F_READ_DATA.
    PERFORM. F_PRINT_REPORT.
  ENDIF.
************************************************************************
* 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_DATA2005 .
  SELECT * INTO CORRESPONDING FIELDS OF TABLE ITAB
   FROM GLT0
   WHERE RYEAR = P_RYEAR AND
         RBUSA = '' AND             "业务范围
         ( BUKRS = '1000' OR
           BUKRS = '2000' OR
           BUKRS = '3000' OR
           BUKRS = '4000' OR
           BUKRS = '5000' OR
           BUKRS = '0999' ) AND
         RACCT > '0010000000'.

  REFRESH ITAB_QM.
  CLEAR ITAB_QM.
  REFRESH ITAB_NC.
  CLEAR ITAB.

*& 开始循环,处理每月期未数
LOOP AT ITAB.
  CASE P_MONAT.
    WHEN '03'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL03.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03.
      ENDIF.
    WHEN '04'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL04.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03 + ITAB-HSL04.
      ENDIF.
    WHEN '05'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL05.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03 + ITAB-HSL04 + ITAB-HSL05.
      ENDIF.
    WHEN '06'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL06.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03 + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06.
      ENDIF.
    WHEN '07'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL07.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03 + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07.
      ENDIF.
    WHEN '08'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL08.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03 + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08.
      ENDIF.
    WHEN '09'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL09.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03 + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09.
      ENDIF.
    WHEN '10'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL10.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03 + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10.
      ENDIF.
    WHEN '11'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL11.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03 + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11.
      ENDIF.
    WHEN '12'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL12.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03 + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
                     + ITAB-HSL12.
      ENDIF.
    WHEN '13'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL13.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03 + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
                     + ITAB-HSL12 + ITAB-HSL13.
      ENDIF.
    WHEN '14'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL14.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03 + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
                     + ITAB-HSL12 + ITAB-HSL13 + ITAB-HSL14.
      ENDIF.
    WHEN '15'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL15.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03 + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
                     + ITAB-HSL12 + ITAB-HSL13 + ITAB-HSL14 + ITAB-HSL15.
      ENDIF.
    WHEN '16'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL16.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSL03 + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
                     + ITAB-HSL12 + ITAB-HSL13 + ITAB-HSL14 + ITAB-HSL15
                     + ITAB-HSL16.
     ENDIF.
  ENDCASE.
  MODIFY ITAB INDEX SY-TABIX.

*  汇总明细科目至总账科目
  "存货
  IF ITAB-RACCT+2(2) = '12'.
    IF ITAB-RACCT+2(8) <> '12329999'.
      ITAB_QM-CH = ITAB_QM-CH + ITAB-TAMOUNT.  "期未数(ITAB_QM)
      ITAB_NC-CH  = ITAB_NC-CH + ITAB-HSLVT.     "期初数(ITAB_NC)
    ENDIF.
  ELSE.
  CASE ITAB-RACCT+2(4).
"====流动资产:
    "货币资金
    WHEN '1001' OR '1002' OR '1009'.
      ITAB_QM-XJ = ITAB_QM-XJ + ITAB-TAMOUNT.  "期未数(ITAB_QM)
      ITAB_NC-XJ  = ITAB_NC-XJ + ITAB-HSLVT.     "期初数(ITAB_NC)
    "短期投资
    WHEN '1101' OR '1102'.
      ITAB_QM-DQTZ = ITAB_QM-DQTZ + ITAB-TAMOUNT.
      ITAB_NC-DQTZ  = ITAB_NC-DQTZ + ITAB-HSLVT.
    "应收票据
    WHEN '1111'.
      ITAB_QM-YSPJ = ITAB_QM-YSPJ + ITAB-TAMOUNT.
      ITAB_NC-YSPJ  = ITAB_NC-YSPJ + ITAB-HSLVT.
    "应收帐款
    WHEN '1131'.
      ITAB_QM-YSZK = ITAB_QM-YSZK + ITAB-TAMOUNT.
      ITAB_NC-YSZK  = ITAB_NC-YSZK + ITAB-HSLVT.
    "减:坏帐准备
    WHEN '1141'.
      ITAB_QM-HZZB = ITAB_QM-HZZB + ITAB-TAMOUNT.
      ITAB_NC-HZZB  = ITAB_NC-HZZB + ITAB-HSLVT.
    "应收帐款净额(略)
    "预付帐款
    WHEN '1151'.
      ITAB_QM-YFZK = ITAB_QM-YFZK + ITAB-TAMOUNT.
      ITAB_NC-YFZK  = ITAB_NC-YFZK + ITAB-HSLVT.
    "应收补贴款
    WHEN '1161'.
      ITAB_QM-YSBTK = ITAB_QM-YSBTK + ITAB-TAMOUNT.
      ITAB_NC-YSBTK  = ITAB_NC-YSBTK + ITAB-HSLVT.
    "其他应收款
    WHEN '1133'.
      ITAB_QM-QTYSK = ITAB_QM-QTYSK + ITAB-TAMOUNT.
      ITAB_NC-QTYSK  = ITAB_NC-QTYSK + ITAB-HSLVT.
    "存货(在上面处理)
    "待摊费用
    WHEN '1301'.
      ITAB_QM-DTFY = ITAB_QM-DTFY + ITAB-TAMOUNT.
      ITAB_NC-DTFY  = ITAB_NC-DTFY + ITAB-HSLVT.
    "待处理流动资产净损失(无)
    "一年内到期的长期债券投资(无)
    "其他流动资产
    WHEN '1498' OR '6001'.
      IF ( ITAB-RACCT+2(8) = '14980001' ) OR ( ITAB-RACCT+2(8) = '14980002' )
       OR ( ITAB-RACCT+2(8) = '60010001' ).
        ITAB_QM-QTLDZC = ITAB_QM-QTLDZC + ITAB-TAMOUNT.
        ITAB_NC-QTLDZC  = ITAB_NC-QTLDZC + ITAB-HSLVT.
      ENDIF.
    "流动资产合计(略)

"====长期投资:
    "长期投资
    WHEN '1401'.
      ITAB_QM-CQTZ = ITAB_QM-CQTZ + ITAB-TAMOUNT.
      ITAB_NC-CQTZ  = ITAB_NC-CQTZ + ITAB-HSLVT.

"====固定资产:
    "固定资产原价
    WHEN '1501'.
      ITAB_QM-GDZCYZ = ITAB_QM-GDZCYZ + ITAB-TAMOUNT.
      ITAB_NC-GDZCYZ  = ITAB_NC-GDZCYZ + ITAB-HSLVT.
    "减:累计折旧
    WHEN '1502'.
      ITAB_QM-LJZJ = ITAB_QM-LJZJ + ITAB-TAMOUNT.
      ITAB_NC-LJZJ  = ITAB_NC-LJZJ + ITAB-HSLVT.
    "固定资产净值(无)
    "固定资产清理
    WHEN '1701'.
      ITAB_QM-GDZCQL = ITAB_QM-GDZCQL + ITAB-TAMOUNT.
      ITAB_NC-GDZCQL  = ITAB_NC-GDZCQL + ITAB-HSLVT.
    "在建工程
    WHEN '1603'.
      ITAB_QM-ZJGC = ITAB_QM-ZJGC + ITAB-TAMOUNT.
      ITAB_NC-ZJGC  = ITAB_NC-ZJGC + ITAB-HSLVT.
    "待处理固定资产净损失
    WHEN '1911'.
      ITAB_QM-GDZCSS = ITAB_QM-GDZCSS + ITAB-TAMOUNT.
      ITAB_NC-GDZCSS  = ITAB_NC-GDZCSS + ITAB-HSLVT.
    "固定资产合计(略)

"====无形资产及递延资产:
    "无形资产
    WHEN '1801'.
      ITAB_QM-WXZC = ITAB_QM-WXZC + ITAB-TAMOUNT.
      ITAB_NC-WXZC  = ITAB_NC-WXZC + ITAB-HSLVT.
    "递延资产(无)
    "无形资产及递延资产合计(略)

"====其他长期资产:
    "其他长期资产
    WHEN '1901'.
      ITAB_QM-QCCQZC = ITAB_QM-QCCQZC + ITAB-TAMOUNT.
      ITAB_NC-QCCQZC  = ITAB_NC-QCCQZC + ITAB-HSLVT.
"====递延税项
    "递延税项借项(无)
    "资产总计(略)

"====流动负债:
    "短期借款
    WHEN '2101'.
      ITAB_QM-DQJK = ITAB_QM-DQJK + ITAB-TAMOUNT.
      ITAB_NC-DQJK  = ITAB_NC-DQJK + ITAB-HSLVT.
    "应付票据
    WHEN '2111'.
      ITAB_QM-YFPJ = ITAB_QM-YFPJ + ITAB-TAMOUNT.
      ITAB_NC-YFPJ  = ITAB_NC-YFPJ + ITAB-HSLVT.
    "应付帐款
    WHEN '2121'.
      ITAB_QM-YIFZK = ITAB_QM-YIFZK + ITAB-TAMOUNT.
      ITAB_NC-YIFZK  = ITAB_NC-YIFZK + ITAB-HSLVT.
    "预收帐款
    WHEN '2131'.
      ITAB_QM-YUSZK = ITAB_QM-YUSZK + ITAB-TAMOUNT.
      ITAB_NC-YUSZK  = ITAB_NC-YUSZK + ITAB-HSLVT.
    "应付工资
    WHEN '2151'.
      ITAB_QM-YFGZ = ITAB_QM-YFGZ + ITAB-TAMOUNT.
      ITAB_NC-YFGZ  = ITAB_NC-YFGZ + ITAB-HSLVT.
    "应付福利费
    WHEN '2153'.
      ITAB_QM-YFFLF = ITAB_QM-YFFLF + ITAB-TAMOUNT.
      ITAB_NC-YFFLF  = ITAB_NC-YFFLF + ITAB-HSLVT.
    "应付股利
    WHEN '2161'.
      ITAB_QM-YFGL = ITAB_QM-YFGL + ITAB-TAMOUNT.
      ITAB_NC-YFGL  = ITAB_NC-YFGL + ITAB-HSLVT.
    "应交税金
    WHEN '2171'.
      ITAB_QM-YJSJ = ITAB_QM-YJSJ + ITAB-TAMOUNT.
      ITAB_NC-YJSJ  = ITAB_NC-YJSJ + ITAB-HSLVT.
    "其他应交款(无)
    "其他应付款
    WHEN '2181'.
      ITAB_QM-QTYFK = ITAB_QM-QTYFK + ITAB-TAMOUNT.
      ITAB_NC-QTYFK  = ITAB_NC-QTYFK + ITAB-HSLVT.
    "预提费用
    WHEN '2191'.
      ITAB_QM-YTFY = ITAB_QM-YTFY + ITAB-TAMOUNT.
      ITAB_NC-YTFY  = ITAB_NC-YTFY + ITAB-HSLVT.
    "一年内到期的长期负债(无)
    "其他流动负债(无)
    "流动负债合计(略)
"====长期负债:(无)
"====递延税项:(无)
"====所有者权益(或股东权益):
    "实收资本(或股本)
    WHEN '3101'.
      ITAB_QM-SSZB = ITAB_QM-SSZB + ITAB-TAMOUNT.
      ITAB_NC-SSZB  = ITAB_NC-SSZB + ITAB-HSLVT.
    "减:已归还投资(无)
    "实收资本(或股本)净额(无)
    "资本公积
    WHEN '3111'.
      ITAB_QM-ZBGJ = ITAB_QM-ZBGJ + ITAB-TAMOUNT.
      ITAB_NC-ZBGJ  = ITAB_NC-ZBGJ + ITAB-HSLVT.
    "盈余公积
    WHEN '3121'.
      ITAB_QM-YYGJ = ITAB_QM-YYGJ + ITAB-TAMOUNT.
      ITAB_NC-YYGJ  = ITAB_NC-YYGJ + ITAB-HSLVT.
    "其中:公益金(无)
    "未分配利润
    WHEN '3141'.
      IF ( ITAB-RACCT+2(8) = '31410015' ) AND ( ITAB-BUKRS = '0999').
        ITAB_QM-WFPLL = ITAB_QM-WFPLL + ITAB-TAMOUNT.
        ITAB_NC-WFPLL  = ITAB_NC-WFPLL + ITAB-HSLVT.
      ENDIF.
    "所有者权益合计(略)
    "负债及所有者权益总计(略)
  ENDCASE.
  ENDIF.

*更新内表ITAB_NC,ITAB_QM
  MODIFY ITAB_NC INDEX SY-TABIX.
  MODIFY ITAB_QM INDEX SY-TABIX.
ENDLOOP.

*应收账款处理、存货处理、应交税金处理(四家公司)
  G_AMOUNT_YSZK = 0.G_AMOUNT_YJSJ = 0.G_AMOUNT_CH = 0.
  G_BUKRS = '1000'. G_DATE_1 = G_DATE1. G_DATE_2 = G_DATE3.
  PERFORM. F_YSZK.
  PERFORM. F_CH.
  PERFORM. F_YJSJ.

  G_BUKRS = '2000'. G_DATE_1 = G_DATE1. G_DATE_2 = G_DATE3.
  PERFORM. F_YSZK.
  PERFORM. F_CH.
  PERFORM. F_YJSJ.

  G_BUKRS = '3000'. G_DATE_1 = G_DATE1. G_DATE_2 = G_DATE3.
  PERFORM. F_YSZK.
  PERFORM. F_CH.
  PERFORM. F_YJSJ.

 G_BUKRS = '4000'. G_DATE_1 = G_DATE1. G_DATE_2 = G_DATE3.
  PERFORM. F_YSZK.
  PERFORM. F_CH.
  PERFORM. F_YJSJ.

 G_BUKRS = '5000'. G_DATE_1 = G_DATE1. G_DATE_2 = G_DATE3.
  PERFORM. F_YSZK.
  PERFORM. F_CH.
  PERFORM. F_YJSJ.

  G_BUKRS = '0999'. G_DATE_1 = G_DATE2. G_DATE_2 = G_DATE3.
  PERFORM. F_YSZK.
  PERFORM. F_CH.
  PERFORM. F_YJSJ.

*未分配利润处理
  PERFORM. F_WFPLL.

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

*最终数据合计及总计
  PERFORM. F_TOTAL.
ENDFORM.                    " F_READ_DATA2005
*&---------------------------------------------------------------------*
*从数据库中读取数据,填充报表输出时所用的内表
*&---------------------------------------------------------------------*
FORM. F_READ_DATA .
  SELECT * INTO CORRESPONDING FIELDS OF TABLE ITAB
   FROM GLT0
   WHERE RYEAR = P_RYEAR AND
         RBUSA = '' AND             "业务范围
         ( BUKRS = '1000' OR
           BUKRS = '2000' OR
           BUKRS = '3000' OR
           BUKRS = '4000' OR
           BUKRS = '5000' OR
           BUKRS = '0999' ) AND
         RACCT > '0010000000'.

  REFRESH ITAB_QM.
  CLEAR ITAB_QM.
  REFRESH ITAB_NC.
  CLEAR ITAB.

*& 开始循环,处理每月期未数
LOOP AT ITAB.
  CASE P_MONAT.
    WHEN '01'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL01.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01.
      ENDIF.
    WHEN '02'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL02.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02.
      ENDIF.
    WHEN '03'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL03.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03.
      ENDIF.
    WHEN '04'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL04.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04.
      ENDIF.
    WHEN '05'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL05.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05.
      ENDIF.
    WHEN '06'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL06.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06.
      ENDIF.
    WHEN '07'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL07.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07.
      ENDIF.
    WHEN '08'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL08.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08.
      ENDIF.
    WHEN '09'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL09.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09.
      ENDIF.
    WHEN '10'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL10.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10.
      ENDIF.
    WHEN '11'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL11.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11.
      ENDIF.
    WHEN '12'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL12.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
                     + ITAB-HSL12.
      ENDIF.
    WHEN '13'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL13.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
                     + ITAB-HSL12 + ITAB-HSL13.
      ENDIF.
    WHEN '14'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL14.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
                     + ITAB-HSL12 + ITAB-HSL13 + ITAB-HSL14.
      ENDIF.
    WHEN '15'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL15.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
                     + ITAB-HSL12 + ITAB-HSL13 + ITAB-HSL14 + ITAB-HSL15.
      ENDIF.
    WHEN '16'.
      IF ITAB-BUKRS = '0999'.
        ITAB-TAMOUNT = ITAB-HSL16.
      ELSE.
        ITAB-TAMOUNT = ITAB-HSLVT + ITAB-HSL01 + ITAB-HSL02 + ITAB-HSL03
                     + ITAB-HSL04 + ITAB-HSL05 + ITAB-HSL06 + ITAB-HSL07
                     + ITAB-HSL08 + ITAB-HSL09 + ITAB-HSL10 + ITAB-HSL11
                     + ITAB-HSL12 + ITAB-HSL13 + ITAB-HSL14 + ITAB-HSL15
                     + ITAB-HSL16.
      ENDIF.
  ENDCASE.
  MODIFY ITAB INDEX SY-TABIX.

*  汇总明细科目至总账科目
  "存货
  IF ITAB-RACCT+2(2) = '12'.
    IF ITAB-RACCT+2(8) <> '12329999'.
      ITAB_QM-CH = ITAB_QM-CH + ITAB-TAMOUNT.  "期未数(ITAB_QM)
      ITAB_NC-CH  = ITAB_NC-CH + ITAB-HSLVT.     "期初数(ITAB_NC)
    ENDIF.
  ELSE.
  CASE ITAB-RACCT+2(4).
"====流动资产:
    "货币资金
    WHEN '1001' OR '1002' OR '1009'.
      ITAB_QM-XJ = ITAB_QM-XJ + ITAB-TAMOUNT.  "期未数(ITAB_QM)
      ITAB_NC-XJ  = ITAB_NC-XJ + ITAB-HSLVT.     "期初数(ITAB_NC)
    "短期投资
    WHEN '1101' OR '1102'.
      ITAB_QM-DQTZ = ITAB_QM-DQTZ + ITAB-TAMOUNT.
      ITAB_NC-DQTZ  = ITAB_NC-DQTZ + ITAB-HSLVT.
    "应收票据
    WHEN '1111'.
      ITAB_QM-YSPJ = ITAB_QM-YSPJ + ITAB-TAMOUNT.
      ITAB_NC-YSPJ  = ITAB_NC-YSPJ + ITAB-HSLVT.
    "应收帐款
    WHEN '1131'.
      ITAB_QM-YSZK = ITAB_QM-YSZK + ITAB-TAMOUNT.
      ITAB_NC-YSZK  = ITAB_NC-YSZK + ITAB-HSLVT.
    "减:坏帐准备
    WHEN '1141'.
      ITAB_QM-HZZB = ITAB_QM-HZZB + ITAB-TAMOUNT.
      ITAB_NC-HZZB  = ITAB_NC-HZZB + ITAB-HSLVT.
    "应收帐款净额(略)
    "预付帐款
    WHEN '1151'.
      ITAB_QM-YFZK = ITAB_QM-YFZK + ITAB-TAMOUNT.
      ITAB_NC-YFZK  = ITAB_NC-YFZK + ITAB-HSLVT.
    "应收补贴款
    WHEN '1161'.
      ITAB_QM-YSBTK = ITAB_QM-YSBTK + ITAB-TAMOUNT.
      ITAB_NC-YSBTK  = ITAB_NC-YSBTK + ITAB-HSLVT.
    "其他应收款
    WHEN '1133'.
      ITAB_QM-QTYSK = ITAB_QM-QTYSK + ITAB-TAMOUNT.
      ITAB_NC-QTYSK  = ITAB_NC-QTYSK + ITAB-HSLVT.
    "存货(在上面处理)
    "待摊费用
    WHEN '1301'.
      ITAB_QM-DTFY = ITAB_QM-DTFY + ITAB-TAMOUNT.
      ITAB_NC-DTFY  = ITAB_NC-DTFY + ITAB-HSLVT.
    "待处理流动资产净损失(无)
    "一年内到期的长期债券投资(无)
    "其他流动资产
    WHEN '1498' OR '6001'.
      IF ( ITAB-RACCT+2(8) = '14980001' ) OR ( ITAB-RACCT+2(8) = '14980002' )
       OR ( ITAB-RACCT+2(8) = '60010001' ).
        ITAB_QM-QTLDZC = ITAB_QM-QTLDZC + ITAB-TAMOUNT.
        ITAB_NC-QTLDZC  = ITAB_NC-QTLDZC + ITAB-HSLVT.
      ENDIF.
    "流动资产合计(略)

"====长期投资:
    "长期投资
    WHEN '1401'.
      ITAB_QM-CQTZ = ITAB_QM-CQTZ + ITAB-TAMOUNT.
      ITAB_NC-CQTZ  = ITAB_NC-CQTZ + ITAB-HSLVT.

"====固定资产:
    "固定资产原价
    WHEN '1501'.
      ITAB_QM-GDZCYZ = ITAB_QM-GDZCYZ + ITAB-TAMOUNT.
      ITAB_NC-GDZCYZ  = ITAB_NC-GDZCYZ + ITAB-HSLVT.
    "减:累计折旧
    WHEN '1502'.
      ITAB_QM-LJZJ = ITAB_QM-LJZJ + ITAB-TAMOUNT.
      ITAB_NC-LJZJ  = ITAB_NC-LJZJ + ITAB-HSLVT.
    "固定资产净值(无)
    "固定资产清理
    WHEN '1701'.
      ITAB_QM-GDZCQL = ITAB_QM-GDZCQL + ITAB-TAMOUNT.
      ITAB_NC-GDZCQL  = ITAB_NC-GDZCQL + ITAB-HSLVT.
    "在建工程
    WHEN '1603'.
      ITAB_QM-ZJGC = ITAB_QM-ZJGC + ITAB-TAMOUNT.
      ITAB_NC-ZJGC  = ITAB_NC-ZJGC + ITAB-HSLVT.
    "待处理固定资产净损失
    WHEN '1911'.
      ITAB_QM-GDZCSS = ITAB_QM-GDZCSS + ITAB-TAMOUNT.
      ITAB_NC-GDZCSS  = ITAB_NC-GDZCSS + ITAB-HSLVT.
    "固定资产合计(略)

"====无形资产及递延资产:
    "无形资产
    WHEN '1801'.
      ITAB_QM-WXZC = ITAB_QM-WXZC + ITAB-TAMOUNT.
      ITAB_NC-WXZC  = ITAB_NC-WXZC + ITAB-HSLVT.
    "递延资产(无)
    "无形资产及递延资产合计(略)

"====其他长期资产:
    "其他长期资产
    WHEN '1901'.
      ITAB_QM-QCCQZC = ITAB_QM-QCCQZC + ITAB-TAMOUNT.
      ITAB_NC-QCCQZC  = ITAB_NC-QCCQZC + ITAB-HSLVT.
"====递延税项
    "递延税项借项(无)
    "资产总计(略)

"====流动负债:
    "短期借款
    WHEN '2101'.
      ITAB_QM-DQJK = ITAB_QM-DQJK + ITAB-TAMOUNT.
      ITAB_NC-DQJK  = ITAB_NC-DQJK + ITAB-HSLVT.
    "应付票据
    WHEN '2111'.
      ITAB_QM-YFPJ = ITAB_QM-YFPJ + ITAB-TAMOUNT.
      ITAB_NC-YFPJ  = ITAB_NC-YFPJ + ITAB-HSLVT.
    "应付帐款
    WHEN '2121'.
      ITAB_QM-YIFZK = ITAB_QM-YIFZK + ITAB-TAMOUNT.
      ITAB_NC-YIFZK  = ITAB_NC-YIFZK + ITAB-HSLVT.
    "预收帐款
    WHEN '2131'.
      ITAB_QM-YUSZK = ITAB_QM-YUSZK + ITAB-TAMOUNT.
      ITAB_NC-YUSZK  = ITAB_NC-YUSZK + ITAB-HSLVT.
    "应付工资
    WHEN '2151'.
      ITAB_QM-YFGZ = ITAB_QM-YFGZ + ITAB-TAMOUNT.
      ITAB_NC-YFGZ  = ITAB_NC-YFGZ + ITAB-HSLVT.
    "应付福利费
    WHEN '2153'.
      ITAB_QM-YFFLF = ITAB_QM-YFFLF + ITAB-TAMOUNT.
      ITAB_NC-YFFLF  = ITAB_NC-YFFLF + ITAB-HSLVT.
    "应付股利
    WHEN '2161'.
      ITAB_QM-YFGL = ITAB_QM-YFGL + ITAB-TAMOUNT.
      ITAB_NC-YFGL  = ITAB_NC-YFGL + ITAB-HSLVT.
    "应交税金
    WHEN '2171'.
      ITAB_QM-YJSJ = ITAB_QM-YJSJ + ITAB-TAMOUNT.
      ITAB_NC-YJSJ  = ITAB_NC-YJSJ + ITAB-HSLVT.
    "其他应交款(无)
    "其他应付款
    WHEN '2181'.
      ITAB_QM-QTYFK = ITAB_QM-QTYFK + ITAB-TAMOUNT.
      ITAB_NC-QTYFK  = ITAB_NC-QTYFK + ITAB-HSLVT.
    "预提费用
    WHEN '2191'.
      ITAB_QM-YTFY = ITAB_QM-YTFY + ITAB-TAMOUNT.
      ITAB_NC-YTFY  = ITAB_NC-YTFY + ITAB-HSLVT.
    "一年内到期的长期负债(无)
    "其他流动负债(无)
    "流动负债合计(略)
"====长期负债:(无)
"====递延税项:(无)
"====所有者权益(或股东权益):
    "实收资本(或股本)
    WHEN '3101'.
      ITAB_QM-SSZB = ITAB_QM-SSZB + ITAB-TAMOUNT.
      ITAB_NC-SSZB  = ITAB_NC-SSZB + ITAB-HSLVT.
    "减:已归还投资(无)
    "实收资本(或股本)净额(无)
    "资本公积
    WHEN '3111'.
      ITAB_QM-ZBGJ = ITAB_QM-ZBGJ + ITAB-TAMOUNT.
      ITAB_NC-ZBGJ  = ITAB_NC-ZBGJ + ITAB-HSLVT.
    "盈余公积
    WHEN '3121'.
      ITAB_QM-YYGJ = ITAB_QM-YYGJ + ITAB-TAMOUNT.
      ITAB_NC-YYGJ  = ITAB_NC-YYGJ + ITAB-HSLVT.
    "其中:公益金(无)
    "未分配利润
    WHEN '3141'.
      IF ( ITAB-RACCT+2(8) = '31410015' ) AND ( ITAB-BUKRS = '0999').
        ITAB_QM-WFPLL = ITAB_QM-WFPLL + ITAB-TAMOUNT.
        ITAB_NC-WFPLL  = ITAB_NC-WFPLL + ITAB-HSLVT.
      ENDIF.
    "所有者权益合计(略)
    "负债及所有者权益总计(略)
  ENDCASE.
  ENDIF.

*更新内表ITAB_NC,ITAB_QM
  MODIFY ITAB_NC INDEX SY-TABIX.
  MODIFY ITAB_QM INDEX SY-TABIX.
ENDLOOP.

*应收账款处理、存货处理、应交税金处理(四家公司)
  G_AMOUNT_YSZK = 0.G_AMOUNT_YJSJ = 0.G_AMOUNT_CH = 0.
  G_BUKRS = '1000'. G_DATE_1 = G_DATE1. G_DATE_2 = G_DATE3.
  PERFORM. F_YSZK.
  PERFORM. F_CH.
  PERFORM. F_YJSJ.

  G_BUKRS = '2000'. G_DATE_1 = G_DATE1. G_DATE_2 = G_DATE3.
  PERFORM. F_YSZK.
  PERFORM. F_CH.
  PERFORM. F_YJSJ.

  G_BUKRS = '3000'. G_DATE_1 = G_DATE1. G_DATE_2 = G_DATE3.
  PERFORM. F_YSZK.
  PERFORM. F_CH.
  PERFORM. F_YJSJ.

  G_BUKRS = '4000'. G_DATE_1 = G_DATE1. G_DATE_2 = G_DATE3.
  PERFORM. F_YSZK.
  PERFORM. F_CH.
  PERFORM. F_YJSJ.

  G_BUKRS = '5000'. G_DATE_1 = G_DATE1. G_DATE_2 = G_DATE3.
  PERFORM. F_YSZK.
  PERFORM. F_CH.
  PERFORM. F_YJSJ.

  G_BUKRS = '0999'. G_DATE_1 = G_DATE2. G_DATE_2 = G_DATE3.
  PERFORM. F_YSZK.
  PERFORM. F_CH.
  PERFORM. F_YJSJ.

*未分配利润处理
  PERFORM. F_WFPLL.

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

*最终数据合计及总计
  PERFORM. F_TOTAL.
ENDFORM.                    " F_READ_DATA
*&---------------------------------------------------------------------*
*&      2005年数据特殊处理
*&      从表ZFI02中取2004年12月31日的期初数据
*&      从表ZFI02中取2005年2月底的本年数
*&---------------------------------------------------------------------*
FORM. F_FIRST_DO.
*取2004年12月31日的期未数据
  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE ITAB_FIRST
    FROM ZFI02
    WHERE RRCTY = '3'.

  LOOP AT ITAB_FIRST.
*-----资产
    ITAB_NC2005-CH = ITAB_FIRST-CH.
    ITAB_NC2005-XJ = ITAB_FIRST-XJ.
    ITAB_NC2005-DQTZ = ITAB_FIRST-DQTZ.
    ITAB_NC2005-YSPJ = ITAB_FIRST-YSPJ.
    ITAB_NC2005-YSZK = ITAB_FIRST-YSZK.
    ITAB_NC2005-HZZB = 0 - ITAB_FIRST-HZZB.
    ITAB_NC2005-YFZK = ITAB_FIRST-YFZK.
    ITAB_NC2005-YSBTK = ITAB_FIRST-YSBTK.
    ITAB_NC2005-QTYSK = ITAB_FIRST-QTYSK.
    ITAB_NC2005-DTFY = ITAB_FIRST-DTFY.
    ITAB_NC2005-QTLDZC = ITAB_FIRST-QTLDZC.
    ITAB_NC2005-CQTZ = ITAB_FIRST-CQTZ.
    ITAB_NC2005-GDZCYZ = ITAB_FIRST-GDZCYZ.
    ITAB_NC2005-LJZJ = 0 - ITAB_FIRST-LJZJ.
    ITAB_NC2005-GDZCQL = ITAB_FIRST-GDZCQL.

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

上一篇: ZR_FI_013
下一篇: ZR_FI_015
请登录后发表评论 登录
全部评论

注册时间:2006-03-01

  • 博文量
    43
  • 访问量
    33216